common/cpp/src/google_smart_card_common/value_emscripten_val_conversion_unittest.cc
TEST(ValueEmscriptenValConversion, IntegerValueError) {
  {
    constexpr int64_t k64BitMax = std::numeric_limits<int64_t>::max();
    const optional<emscripten::val> converted =
        ConvertValueToEmscriptenVal(Value(k64BitMax));
    EXPECT_FALSE(converted);
  }

  {
    constexpr int64_t k64BitMin = std::numeric_limits<int64_t>::min();
    std::string error_message;
    const optional<emscripten::val> converted =
        ConvertValueToEmscriptenVal(Value(k64BitMin), &error_message);
    EXPECT_FALSE(converted);
    EXPECT_THAT(
        error_message,
        MatchesRegex("The integer -9223372036854775808 cannot be converted "
                     "into a floating-point double value without loss of "
                     "precision: it is outside .* range"));
  }
}
// Test that conversion of huge integers fails (as JavaScript numbers cannot
// store them precisely).
Test that conversion of huge integers fails (as JavaScript numbers cannot
store them precisely).
Test that conversion of huge integers fails ( as JavaScript numbers cannot store them precisely ) .
TEST(ValueEmscriptenValConversion, IntegerValueError) {
  {
    constexpr int64_t k64BitMax = std::numeric_limits<int64_t>::max();
    const optional<emscripten::val> converted =
        ConvertValueToEmscriptenVal(Value(k64BitMax));
    EXPECT_FALSE(converted);
  }
  {
    constexpr int64_t k64BitMin = std::numeric_limits<int64_t>::min();
    std::string error_message;
    const optional<emscripten::val> converted =
        ConvertValueToEmscriptenVal(Value(k64BitMin), &error_message);
    EXPECT_FALSE(converted);
    EXPECT_THAT(
        error_message,
        MatchesRegex("The integer -9223372036854775808 cannot be converted "
                     "into a floating-point double value without loss of "
                     "precision: it is outside .* range"));
  }
}
TEST ( ValueEmscriptenValConversion , IntegerValueError ) { { constexpr int64_t k64BitMax = std :: numeric_limits < int64_t > :: max ( ) ; const optional < emscripten :: val > converted = ConvertValueToEmscriptenVal ( Value ( k64BitMax ) ) ; EXPECT_FALSE ( converted ) ; } { constexpr int64_t k64BitMin = std :: numeric_limits < int64_t > :: min ( ) ; std :: string error_message ; const optional < emscripten :: val > converted = ConvertValueToEmscriptenVal ( Value ( k64BitMin ) , & error_message ) ; EXPECT_FALSE ( converted ) ; EXPECT_THAT ( error_message , MatchesRegex ( " " " " " " ) ) ; } }
Test that conversion of huge integers fails (as JavaScript numbers cannot
store them precisely).
Test that conversion of huge integers fails ( as JavaScript numbers cannot store them precisely ) .