Add ICU message format support
[chromium-blink-merge.git] / tools / gn / args_unittest.cc
blob098f3dec8504975a55a136204f196cc12b74bd4c
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "tools/gn/args.h"
7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "tools/gn/scheduler.h"
9 #include "tools/gn/test_with_scope.h"
11 // Assertions for VerifyAllOverridesUsed() and DeclareArgs() with multiple
12 // toolchains.
13 TEST(ArgsTest, VerifyAllOverridesUsed) {
14 TestWithScope setup1, setup2;
15 Args args;
16 Scope::KeyValueMap key_value_map1;
17 Err err;
18 LiteralNode assignment1;
20 setup1.scope()->SetValue("a", Value(nullptr, true), &assignment1);
21 setup1.scope()->GetCurrentScopeValues(&key_value_map1);
22 EXPECT_TRUE(args.DeclareArgs(key_value_map1, setup1.scope(), &err));
24 LiteralNode assignment2;
25 setup2.scope()->SetValue("b", Value(nullptr, true), &assignment2);
26 Scope::KeyValueMap key_value_map2;
27 setup2.scope()->GetCurrentScopeValues(&key_value_map2);
28 EXPECT_TRUE(args.DeclareArgs(key_value_map2, setup2.scope(), &err));
30 // Override "a", shouldn't see any errors as "a" was defined.
31 args.AddArgOverride("a", Value(nullptr, true));
32 EXPECT_TRUE(args.VerifyAllOverridesUsed(&err));
34 // Override "a", & "b", shouldn't see any errors as both were defined.
35 args.AddArgOverride("b", Value(nullptr, true));
36 EXPECT_TRUE(args.VerifyAllOverridesUsed(&err));
38 // Override "a", "b" and "c", should fail as "c" was not defined.
39 args.AddArgOverride("c", Value(nullptr, true));
40 EXPECT_FALSE(args.VerifyAllOverridesUsed(&err));