nds2-client - ClientDeveloper  0.16.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
status_codes.hh
Go to the documentation of this file.
1 //
2 // Created by jonathan.hanks on 4/22/17.
3 //
4 
5 #ifndef NDS_PROXY_STATUS_CODES_HH_HH
6 #define NDS_PROXY_STATUS_CODES_HH_HH
7 
8 #include <array>
9 
10 namespace nds_impl
11 {
12  namespace common
13  {
14  typedef std::array< char, 4 > status_code;
15 
16  const auto STATUS_DAQD_OK = status_code{ '0', '0', '0', '0' };
17  const auto STATUS_DAQD_ERROR = status_code{ '0', '0', '0', '1' };
19  status_code{ '0', '0', '0', 'b' };
20  const auto STATUS_DAQD_NOT_FOUND = status_code{ '0', '0', '0', 'd' };
21  const auto STATUS_DAQD_SYNTAX = status_code{ '0', '0', '1', '9' };
22  const auto STATUS_DAQD_ON_TAPE = status_code{ '0', '0', '1', 'a' };
23  }
24 }
25 
27 // Tests only after this point.
29 
30 #ifdef _NDS_IMPL_ENABLE_CATCH_TESTS_
31 
32 #include <string>
33 #include "catch.hpp"
34 
35 TEST_CASE( "Verify status codes exist", "[status_codes]" )
36 {
37  auto status_to_str =
38  []( const nds_impl::common::status_code& code ) -> std::string {
39  return std::string( code.data( ), code.size( ) );
40  };
41  using namespace nds_impl::common;
42  REQUIRE( status_to_str( STATUS_DAQD_OK ) == "0000" );
43  REQUIRE( status_to_str( STATUS_DAQD_ERROR ) == "0001" );
44  REQUIRE( status_to_str( STATUS_DAQD_VERSION_MISMATCH ) == "000b" );
45  REQUIRE( status_to_str( STATUS_DAQD_SYNTAX ) == "0019" );
46  REQUIRE( status_to_str( STATUS_DAQD_ON_TAPE ) == "001a" );
47  REQUIRE( status_to_str( STATUS_DAQD_NOT_FOUND ) == "000d" );
48 }
49 
50 #endif // _NDS_IMPL_ENABLE_CATCH_TESTS_
51 
52 #endif // NDS_PROXY_STATUS_CODES_HH_HH
std::array< char, 4 > status_code
Definition: status_codes.hh:14
const auto STATUS_DAQD_ON_TAPE
Definition: status_codes.hh:22
const auto STATUS_DAQD_OK
Definition: status_codes.hh:16
TEST_CASE("daq_strlcpy copies strings safely when buffers are sufficiently large")
Definition: test_bsd_string.cc:9
const auto STATUS_DAQD_ERROR
Definition: status_codes.hh:17
const auto STATUS_DAQD_VERSION_MISMATCH
Definition: status_codes.hh:18
const auto STATUS_DAQD_NOT_FOUND
Definition: status_codes.hh:20
const auto STATUS_DAQD_SYNTAX
Definition: status_codes.hh:21