1 // Copyright 2016 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.
4 
5 #include "remoting/host/host_attributes.h"
6 
7 #include <algorithm>
8 #include <vector>
9 
10 #include "base/strings/string_split.h"
11 #include "build/build_config.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13 
14 namespace remoting {
15 
16 // Ensures there is no DCHECK failure or crash in Register() and Callbacks.
TEST(HostAttributesTest,Sanity)17 TEST(HostAttributesTest, Sanity) {
18   std::string result = GetHostAttributes();
19 #if defined(NDEBUG)
20   ASSERT_EQ(result.find("Debug-Build"), std::string::npos);
21 #else
22   ASSERT_NE(result.find("Debug-Build"), std::string::npos);
23 #endif
24 }
25 
TEST(HostAttributesTest,NoDuplicateKeys)26 TEST(HostAttributesTest, NoDuplicateKeys) {
27   std::vector<std::string> results = base::SplitString(GetHostAttributes(),
28                                                        ",",
29                                                        base::KEEP_WHITESPACE,
30                                                        base::SPLIT_WANT_ALL);
31   for (auto it = results.begin(); it != results.end(); it++) {
32     ASSERT_EQ(std::find(it + 1, results.end(), *it), results.end());
33   }
34 }
35 
36 }  // namespace remoting
37