1 // Copyright 2019 The PDFium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "fxjs/xfa/cfxjse_value.h" 6 7 #include <memory> 8 #include <utility> 9 #include <vector> 10 11 #include "fxjs/xfa/cfxjse_engine.h" 12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/xfa_js_embedder_test.h" 14 15 class CFXJSE_ValueEmbedderTest : public XFAJSEmbedderTest {}; 16 TEST_F(CFXJSE_ValueEmbedderTest,Empty)17TEST_F(CFXJSE_ValueEmbedderTest, Empty) { 18 ASSERT_TRUE(OpenDocument("simple_xfa.pdf")); 19 20 auto pValue = std::make_unique<CFXJSE_Value>(); 21 EXPECT_TRUE(pValue->IsEmpty()); 22 EXPECT_FALSE(pValue->IsUndefined(isolate())); 23 EXPECT_FALSE(pValue->IsNull(isolate())); 24 EXPECT_FALSE(pValue->IsBoolean(isolate())); 25 EXPECT_FALSE(pValue->IsString(isolate())); 26 EXPECT_FALSE(pValue->IsNumber(isolate())); 27 EXPECT_FALSE(pValue->IsObject(isolate())); 28 EXPECT_FALSE(pValue->IsArray(isolate())); 29 EXPECT_FALSE(pValue->IsFunction(isolate())); 30 } 31 TEST_F(CFXJSE_ValueEmbedderTest,EmptyArrayInsert)32TEST_F(CFXJSE_ValueEmbedderTest, EmptyArrayInsert) { 33 ASSERT_TRUE(OpenDocument("simple_xfa.pdf")); 34 35 // Test inserting empty values into arrays. 36 auto pValue = std::make_unique<CFXJSE_Value>(); 37 std::vector<std::unique_ptr<CFXJSE_Value>> vec; 38 vec.push_back(std::move(pValue)); 39 40 CFXJSE_Value array; 41 array.SetArray(isolate(), vec); 42 EXPECT_TRUE(array.IsArray(isolate())); 43 } 44