Skip to content

Commit

Permalink
use int8_t for unit testing char Rep output
Browse files Browse the repository at this point in the history
  • Loading branch information
hoffbrinkle committed Feb 5, 2024
1 parent 71ed45e commit 3689593
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion au/io_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#include "au/io.hh"

#include <cstdint>

#include "au/prefix.hh"
#include "au/quantity.hh"
#include "gtest/gtest.h"
Expand Down Expand Up @@ -61,7 +63,13 @@ TEST(StreamingOutput, PrintsValueAndUnitLabel) {
EXPECT_EQ(stream_to_string((feet / milli(second))(1.25)), "1.25 ft / ms");
}

TEST(StreamingOutput, PrintValueRepChar) { EXPECT_EQ(stream_to_string(feet(char{3})), "3 ft"); }
TEST(StreamingOutput, PrintValueRepChar) {
// If the Rep resolves to a char, we sill want the number '65' to be output,
// not the character literal that corresponds to 65 ('A').
static_assert(std::is_same<int8_t, signed char>::value,
"Expected 'int8_t' to resolve to 'char'");
EXPECT_EQ(stream_to_string(feet(int8_t{65})), "65 ft");
}

TEST(StreamingOutput, DistinguishesPointFromQuantityByAtSign) {
EXPECT_EQ(stream_to_string(celsius_qty(20)), "20 deg C");
Expand Down

0 comments on commit 3689593

Please sign in to comment.