OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gin/converter.h" | 5 #include "gin/converter.h" |
6 | 6 |
7 #include <limits.h> | 7 #include <limits.h> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 HandleScope handle_scope(instance_->isolate()); | 72 HandleScope handle_scope(instance_->isolate()); |
73 | 73 |
74 int test_data_to[] = {-1, 0, 1}; | 74 int test_data_to[] = {-1, 0, 1}; |
75 for (size_t i = 0; i < arraysize(test_data_to); ++i) { | 75 for (size_t i = 0; i < arraysize(test_data_to); ++i) { |
76 EXPECT_TRUE(Converter<int32_t>::ToV8(instance_->isolate(), test_data_to[i]) | 76 EXPECT_TRUE(Converter<int32_t>::ToV8(instance_->isolate(), test_data_to[i]) |
77 ->StrictEquals( | 77 ->StrictEquals( |
78 Integer::New(instance_->isolate(), test_data_to[i]))); | 78 Integer::New(instance_->isolate(), test_data_to[i]))); |
79 } | 79 } |
80 | 80 |
81 struct { | 81 struct { |
82 v8::Handle<v8::Value> input; | 82 v8::Local<v8::Value> input; |
83 bool expect_sucess; | 83 bool expect_sucess; |
84 int expected_result; | 84 int expected_result; |
85 } test_data_from[] = { | 85 } test_data_from[] = { |
86 { Boolean::New(instance_->isolate(), false).As<Value>(), false, 0 }, | 86 { Boolean::New(instance_->isolate(), false).As<Value>(), false, 0 }, |
87 { Boolean::New(instance_->isolate(), true).As<Value>(), false, 0 }, | 87 { Boolean::New(instance_->isolate(), true).As<Value>(), false, 0 }, |
88 { Integer::New(instance_->isolate(), -1).As<Value>(), true, -1 }, | 88 { Integer::New(instance_->isolate(), -1).As<Value>(), true, -1 }, |
89 { Integer::New(instance_->isolate(), 0).As<Value>(), true, 0 }, | 89 { Integer::New(instance_->isolate(), 0).As<Value>(), true, 0 }, |
90 { Integer::New(instance_->isolate(), 1).As<Value>(), true, 1 }, | 90 { Integer::New(instance_->isolate(), 1).As<Value>(), true, 1 }, |
91 { Number::New(instance_->isolate(), -1).As<Value>(), true, -1 }, | 91 { Number::New(instance_->isolate(), -1).As<Value>(), true, -1 }, |
92 { Number::New(instance_->isolate(), 1.1).As<Value>(), false, 0 }, | 92 { Number::New(instance_->isolate(), 1.1).As<Value>(), false, 0 }, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 ->StrictEquals(js_array->Get(static_cast<int>(i)))); | 125 ->StrictEquals(js_array->Get(static_cast<int>(i)))); |
126 } | 126 } |
127 | 127 |
128 std::vector<int> actual; | 128 std::vector<int> actual; |
129 EXPECT_TRUE(Converter<std::vector<int> >::FromV8(instance_->isolate(), | 129 EXPECT_TRUE(Converter<std::vector<int> >::FromV8(instance_->isolate(), |
130 js_array, &actual)); | 130 js_array, &actual)); |
131 EXPECT_EQ(expected, actual); | 131 EXPECT_EQ(expected, actual); |
132 } | 132 } |
133 | 133 |
134 } // namespace gin | 134 } // namespace gin |
OLD | NEW |