Skip to content

Commit

Permalink
Further simplify build
Browse files Browse the repository at this point in the history
  • Loading branch information
bifurcation committed Dec 13, 2023
1 parent 0bb1b40 commit 27bfbf5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_subdirectory(bytes)
# add_subdirectory(bytes)
# add_subdirectory(hpke)
add_subdirectory(tls_syntax)
# add_subdirectory(mls_vectors)
6 changes: 4 additions & 2 deletions lib/tls_syntax/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ find_package(doctest REQUIRED)
file(GLOB TEST_SOURCES CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)

add_executable(${TEST_APP_NAME} ${TEST_SOURCES})
add_dependencies(${TEST_APP_NAME} ${CURRENT_LIB_NAME} bytes)
target_link_libraries(${TEST_APP_NAME} ${CURRENT_LIB_NAME} bytes doctest::doctest)
add_dependencies(${TEST_APP_NAME} ${CURRENT_LIB_NAME})
target_link_libraries(${TEST_APP_NAME} ${CURRENT_LIB_NAME} doctest::doctest)
# add_dependencies(${TEST_APP_NAME} ${CURRENT_LIB_NAME} bytes)
# target_link_libraries(${TEST_APP_NAME} ${CURRENT_LIB_NAME} bytes doctest::doctest)

# Enable CTest
include(doctest)
Expand Down
16 changes: 15 additions & 1 deletion lib/tls_syntax/test/tls_syntax.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#include <bytes/bytes.h>
// #include <bytes/bytes.h>
#include <doctest/doctest.h>
#include <namespace.h>
#include <tls/tls_syntax.h>

#if 0
using namespace MLS_NAMESPACE::bytes_ns;
#endif // 0

// An enum to test enum encoding, and as a type for variants
enum struct IntType : uint16_t
Expand Down Expand Up @@ -42,16 +44,19 @@ struct ExampleStruct
MLS_NAMESPACE::tls::varint)
};

#if 0
static bool
operator==(const ExampleStruct& lhs, const ExampleStruct& rhs)
{
return (lhs.a == rhs.a) && (lhs.b == rhs.b) && (lhs.c == rhs.c);
}
#endif

// Known-answer tests
class TLSSyntaxTest
{
protected:
#if 0
const bool val_bool = true;
const bytes enc_bool = from_hex("01");

Expand Down Expand Up @@ -94,6 +99,7 @@ class TLSSyntaxTest

const IntType val_enum = IntType::uint8;
const bytes enc_enum = from_hex("aaaa");
#endif // 0
};

template<typename T>
Expand All @@ -108,6 +114,7 @@ ostream_test(T val, const std::vector<uint8_t>& enc)

TEST_CASE_FIXTURE(TLSSyntaxTest, "TLS ostream")
{
#if 0
bytes answer{ 1, 2, 3, 4 };
MLS_NAMESPACE::tls::ostream w;
w.write_raw(answer);
Expand All @@ -124,6 +131,7 @@ TEST_CASE_FIXTURE(TLSSyntaxTest, "TLS ostream")
ostream_test(val_optional, enc_optional);
ostream_test(val_optional_null, enc_optional_null);
ostream_test(val_enum, enc_enum);
#endif // 0
}

template<typename T>
Expand All @@ -138,6 +146,7 @@ istream_test(T val, T& data, const std::vector<uint8_t>& enc)

TEST_CASE_FIXTURE(TLSSyntaxTest, "TLS istream")
{
#if 0
bool data_bool = false;
istream_test(val_bool, data_bool, enc_bool);

Expand Down Expand Up @@ -170,10 +179,12 @@ TEST_CASE_FIXTURE(TLSSyntaxTest, "TLS istream")

IntType data_enum = IntType::uint16;
istream_test(val_enum, data_enum, enc_enum);
#endif // 0
}

TEST_CASE_FIXTURE(TLSSyntaxTest, "TLS abbreviations")
{
#if 0
ExampleStruct val_in = val_struct;

MLS_NAMESPACE::tls::ostream w;
Expand All @@ -188,10 +199,12 @@ TEST_CASE_FIXTURE(TLSSyntaxTest, "TLS abbreviations")

auto val_out2 = MLS_NAMESPACE::tls::get<ExampleStruct>(marshaled);
REQUIRE(val_in == val_out2);
#endif // 0
}

TEST_CASE("TLS varint failure cases")
{
#if 0
// Encoding a value that is to large
MLS_NAMESPACE::tls::ostream w;
// NOLINTNEXTLINE(llvm-else-after-return, readability-else-after-return)
Expand All @@ -209,6 +222,7 @@ TEST_CASE("TLS varint failure cases")
// NOLINTNEXTLINE(llvm-else-after-return, readability-else-after-return)
REQUIRE_THROWS(MLS_NAMESPACE::tls::varint::decode(r, val));
}
#endif // 0
}

// TODO(rlb@ipv.sx) Test failure cases

0 comments on commit 27bfbf5

Please sign in to comment.