blob: f9bec8797bb132af3d422d03386439ed1f052f6b [file] [log] [blame]
Armando Montanez179aa8e2021-03-10 11:46:35 -08001// Copyright 2021 The Pigweed Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License"); you may not
4// use this file except in compliance with the License. You may obtain a copy of
5// the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12// License for the specific language governing permissions and limitations under
13// the License.
14
15#include <span>
16
17#include "gtest/gtest.h"
18#include "pw_protobuf/encoder.h"
19#include "pw_snapshot_protos/snapshot.pwpb.h"
20
21namespace pw::snapshot {
22namespace {
23
Armando Montanez179aa8e2021-03-10 11:46:35 -080024TEST(Status, CompileTest) {
Armando Montanez32988e02021-05-21 11:56:09 -070025 constexpr size_t kMaxProtoSize = 256;
26 std::byte encode_buffer[kMaxProtoSize];
27 std::byte submessage_buffer[kMaxProtoSize];
28
29 stream::MemoryWriter writer(encode_buffer);
30 Snapshot::StreamEncoder snapshot_encoder(writer, submessage_buffer);
Armando Montanez179aa8e2021-03-10 11:46:35 -080031 {
Armando Montanez32988e02021-05-21 11:56:09 -070032 Metadata::StreamEncoder metadata_encoder =
Armando Montanez179aa8e2021-03-10 11:46:35 -080033 snapshot_encoder.GetMetadataEncoder();
Adrien Larbanetd1ca56c2021-06-10 14:20:45 +000034 metadata_encoder
35 .WriteReason(
36 std::as_bytes(std::span("It just died, I didn't do anything")))
37 .IgnoreError(); // TODO(pwbug/387): Handle Status properly
38 metadata_encoder.WriteFatal(true)
39 .IgnoreError(); // TODO(pwbug/387): Handle Status properly
40 metadata_encoder.WriteProjectName(std::as_bytes(std::span("smart-shoe")))
41 .IgnoreError(); // TODO(pwbug/387): Handle Status properly
42 metadata_encoder.WriteDeviceName(std::as_bytes(std::span("smart-shoe-p1")))
43 .IgnoreError(); // TODO(pwbug/387): Handle Status properly
Armando Montanez179aa8e2021-03-10 11:46:35 -080044 }
Armando Montanez32988e02021-05-21 11:56:09 -070045 ASSERT_TRUE(snapshot_encoder.status().ok());
Armando Montanez179aa8e2021-03-10 11:46:35 -080046}
47
48} // namespace
49} // namespace pw::snapshot