common/cpp/src/google_smart_card_common/value_emscripten_val_conversion_unittest.cc
TEST(ValueEmscriptenValConversion, EmscriptenValOrDie) {
  {
    constexpr bool kBoolean = false;
    const Value value =
        ConvertEmscriptenValToValueOrDie(emscripten::val(kBoolean));
    ASSERT_TRUE(value.is_boolean());
    EXPECT_EQ(value.GetBoolean(), kBoolean);
  }

  {
    const int kInteger = 123;
    const Value value =
        ConvertEmscriptenValToValueOrDie(emscripten::val(kInteger));
    ASSERT_TRUE(value.is_integer());
    EXPECT_EQ(value.GetInteger(), kInteger);
  }

  {
    emscripten::val object_val = emscripten::val::object();
    object_val.set("foo", emscripten::val::null());

    const Value value = ConvertEmscriptenValToValueOrDie(object_val);
    ASSERT_TRUE(value.is_dictionary());
    EXPECT_EQ(value.GetDictionary().size(), 1U);
    const Value* foo_value = value.GetDictionaryItem("foo");
    ASSERT_TRUE(foo_value);
    EXPECT_TRUE(foo_value->is_null());
  }
}
// Test that `ConvertEmscriptenValToValueOrDie()` succeeds on supported inputs.
// As death tests aren't supported, we don't test failure scenarios.
Test that `ConvertEmscriptenValToValueOrDie()` succeeds on supported inputs.
As death tests aren't supported, we don't test failure scenarios.
Test that ` ConvertEmscriptenValToValueOrDie () ` succeeds on supported inputs . As death tests aren ' t supported we don ' t test failure scenarios .
TEST(ValueEmscriptenValConversion, EmscriptenValOrDie) {
  {
    constexpr bool kBoolean = false;
    const Value value =
        ConvertEmscriptenValToValueOrDie(emscripten::val(kBoolean));
    ASSERT_TRUE(value.is_boolean());
    EXPECT_EQ(value.GetBoolean(), kBoolean);
  }
  {
    const int kInteger = 123;
    const Value value =
        ConvertEmscriptenValToValueOrDie(emscripten::val(kInteger));
    ASSERT_TRUE(value.is_integer());
    EXPECT_EQ(value.GetInteger(), kInteger);
  }
  {
    emscripten::val object_val = emscripten::val::object();
    object_val.set("foo", emscripten::val::null());
    const Value value = ConvertEmscriptenValToValueOrDie(object_val);
    ASSERT_TRUE(value.is_dictionary());
    EXPECT_EQ(value.GetDictionary().size(), 1U);
    const Value* foo_value = value.GetDictionaryItem("foo");
    ASSERT_TRUE(foo_value);
    EXPECT_TRUE(foo_value->is_null());
  }
}
TEST ( ValueEmscriptenValConversion , EmscriptenValOrDie ) { { constexpr bool kBoolean = false ; const Value value = ConvertEmscriptenValToValueOrDie ( emscripten :: val ( kBoolean ) ) ; ASSERT_TRUE ( value . is_boolean ( ) ) ; EXPECT_EQ ( value . GetBoolean ( ) , kBoolean ) ; } { const int kInteger = 123 ; const Value value = ConvertEmscriptenValToValueOrDie ( emscripten :: val ( kInteger ) ) ; ASSERT_TRUE ( value . is_integer ( ) ) ; EXPECT_EQ ( value . GetInteger ( ) , kInteger ) ; } { emscripten :: val object_val = emscripten :: val :: object ( ) ; object_val . set ( " " , emscripten :: val :: null ( ) ) ; const Value value = ConvertEmscriptenValToValueOrDie ( object_val ) ; ASSERT_TRUE ( value . is_dictionary ( ) ) ; EXPECT_EQ ( value . GetDictionary ( ) . size ( ) , 1U ) ; const Value * foo_value = value . GetDictionaryItem ( " " ) ; ASSERT_TRUE ( foo_value ) ; EXPECT_TRUE ( foo_value -> is_null ( ) ) ; } }
Test that `ConvertEmscriptenValToValueOrDie()` succeeds on supported inputs.
Test that ` ConvertEmscriptenValToValueOrDie () ` succeeds on supported inputs .