Skip to content

Commit

Permalink
split hex tests and add a couple of extra cases
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjnixon authored and benjamin-weiss committed Aug 14, 2019
1 parent e5052f4 commit ecb447b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tests/hex_values_tests.cpp
@@ -1,14 +1,20 @@
#include <catch2/catch.hpp>
#include "adm/detail/hex_values.hpp"

TEST_CASE("hex_values") {
using namespace adm;
using namespace adm;

TEST_CASE("parseHexValue") {
REQUIRE(detail::parseHexValue("0000") == 0);
REQUIRE(detail::parseHexValue("FFFF") == 65535);
REQUIRE(detail::parseHexValue("0a0F") == 2575);
REQUIRE(detail::parseHexValue("00ff") == 255);
REQUIRE(detail::parseHexValue("ff") == 255);
REQUIRE_THROWS_AS(detail::parseHexValue("ffff0"), std::runtime_error);
REQUIRE_THROWS_AS(detail::parseHexValue("fff "), std::runtime_error);
REQUIRE(detail::parseHexValue("ffff0", 8) == 1048560);
}

TEST_CASE("formatHexValue") {
REQUIRE(detail::formatHexValue(255) == "00ff");
REQUIRE(detail::formatHexValue(255, 2) == "ff");
REQUIRE(detail::formatHexValue(65535, 8) == "0000ffff");
Expand Down

0 comments on commit ecb447b

Please sign in to comment.