status_test.cc 1.1 KB

1234567891011121314151617181920212223242526272829
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "status.h"
  5. #include "status_test_support.h"
  6. #include "test_platform.h"
  7. namespace crdtp {
  8. // =============================================================================
  9. // Status and Error codes
  10. // =============================================================================
  11. TEST(StatusTest, StatusToASCIIString) {
  12. Status ok_status;
  13. EXPECT_EQ("OK", ok_status.ToASCIIString());
  14. Status json_error(Error::JSON_PARSER_COLON_EXPECTED, 42);
  15. EXPECT_EQ("JSON: colon expected at position 42", json_error.ToASCIIString());
  16. Status cbor_error(Error::CBOR_TRAILING_JUNK, 21);
  17. EXPECT_EQ("CBOR: trailing junk at position 21", cbor_error.ToASCIIString());
  18. }
  19. TEST(StatusTest, StatusTestSupport) {
  20. Status ok_status;
  21. EXPECT_THAT(ok_status, StatusIsOk());
  22. Status json_error(Error::JSON_PARSER_COLON_EXPECTED, 42);
  23. EXPECT_THAT(json_error, StatusIs(Error::JSON_PARSER_COLON_EXPECTED, 42));
  24. }
  25. } // namespace crdtp