// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "testing/gtest/include/gtest/gtest.h"
#include "tools/gn/value.h"

TEST(Value, ToString) {
  Value strval(NULL, "hi\" $me\\you\\$\\\"");
  EXPECT_EQ("hi\" $me\\you\\$\\\"", strval.ToString(false));
  EXPECT_EQ("\"hi\\\" \\$me\\you\\\\\\$\\\\\\\"\"", strval.ToString(true));

  // Test lists, bools, and ints.
  Value listval(NULL, Value::LIST);
  listval.list_value().push_back(Value(NULL, "hi\"me"));
  listval.list_value().push_back(Value(NULL, true));
  listval.list_value().push_back(Value(NULL, false));
  listval.list_value().push_back(Value(NULL, static_cast<int64>(42)));
  // Printing lists always causes embedded strings to be quoted (ignoring the
  // quote flag), or else they wouldn't make much sense.
  EXPECT_EQ("[\"hi\\\"me\", true, false, 42]", listval.ToString(false));
  EXPECT_EQ("[\"hi\\\"me\", true, false, 42]", listval.ToString(true));

  // Some weird types, we may want to enhance or change printing of these, but
  // here we test the current behavior.
  EXPECT_EQ("<void>", Value().ToString(false));
  EXPECT_EQ("<scope>", Value(NULL, Value::SCOPE).ToString(false));
}


Add missing GN test file.
Add missing GN test file.

This was missing from the last upload of https://codereview.chromium.org/265693003 but was present in the initial review.

TBR=scottmg
BUG=

Review URL: https://codereview.chromium.org/265883014

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@268043 0039d316-1c4b-4281-b951-d872f2087c98
