// Copyright 2017 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "components/cbor/writer.h" #include <cmath> #include <limits> #include <string> #include <string_view> #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" /* Leveraging RFC 7049 examples from https://github.com/cbor/test-vectors/blob/master/appendix_a.json. */ namespace cbor { TEST(CBORWriterTest, TestWriteUint) { … } TEST(CBORWriterTest, TestWriteNegativeInteger) { … } TEST(CBORWriterTest, TestWriteBytes) { … } TEST(CBORWriterTest, TestWriteString) { … } TEST(CBORWriterTest, TestWriteArray) { … } TEST(CBORWriterTest, TestWriteMap) { … } TEST(CBORWriterTest, TestWriteMapWithArray) { … } TEST(CBORWriterTest, TestWriteNestedMap) { … } TEST(CBORWriterTest, TestSignedExchangeExample) { … } TEST(CBORWriterTest, TestWriteSimpleValue) { … } TEST(CBORWriterTest, TestWriteFloat) { … } // For major type 0, 2, 3, empty CBOR array, and empty CBOR map, the nesting // depth is expected to be 0 since the CBOR decoder does not need to parse // any nested CBOR value elements. TEST(CBORWriterTest, TestWriteSingleLayer) { … } // Major type 5 nested CBOR map value with following structure. // {"a": 1, // "b": {"c": 2, // "d": 3}} TEST(CBORWriterTest, NestedMaps) { … } // Testing Write() function for following CBOR structure with depth of 3. // [1, // 2, // 3, // {"a": 1, // "b": {"c": 2, // "d": 3}}] TEST(CBORWriterTest, UnbalancedNestedContainers) { … } // Testing Write() function for following CBOR structure. // {"a": 1, // "b": {"c": 2, // "d": 3 // "h": { "e": 4, // "f": 5, // "g": [6, 7, [8]]}}} // Since above CBOR contains 5 nesting levels. Thus, Write() is expected to // return empty optional object when maximum nesting layer size is set to 4. TEST(CBORWriterTest, OverlyNestedCBOR) { … } } // namespace cbor