OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/installer/util/shell_util.h" | 5 #include "chrome/installer/util/shell_util.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <vector> | 10 #include <vector> |
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 ASSERT_TRUE(ShellUtil::GetOldUserSpecificRegistrySuffix(&suffix)); | 998 ASSERT_TRUE(ShellUtil::GetOldUserSpecificRegistrySuffix(&suffix)); |
999 ASSERT_TRUE(base::StartsWith(suffix, L".", base::CompareCase::SENSITIVE)); | 999 ASSERT_TRUE(base::StartsWith(suffix, L".", base::CompareCase::SENSITIVE)); |
1000 | 1000 |
1001 wchar_t user_name[256]; | 1001 wchar_t user_name[256]; |
1002 DWORD size = arraysize(user_name); | 1002 DWORD size = arraysize(user_name); |
1003 ASSERT_NE(0, ::GetUserName(user_name, &size)); | 1003 ASSERT_NE(0, ::GetUserName(user_name, &size)); |
1004 ASSERT_GE(size, 1U); | 1004 ASSERT_GE(size, 1U); |
1005 ASSERT_STREQ(user_name, suffix.substr(1).c_str()); | 1005 ASSERT_STREQ(user_name, suffix.substr(1).c_str()); |
1006 } | 1006 } |
1007 | 1007 |
1008 TEST(ShellUtilTest, ByteArrayToBase32) { | |
1009 // Tests from http://tools.ietf.org/html/rfc4648#section-10. | |
1010 const unsigned char test_array[] = { 'f', 'o', 'o', 'b', 'a', 'r' }; | |
1011 | |
1012 const base::string16 expected[] = { L"", L"MY", L"MZXQ", L"MZXW6", L"MZXW6YQ", | |
1013 L"MZXW6YTB", L"MZXW6YTBOI"}; | |
1014 | |
1015 // Run the tests, with one more letter in the input every pass. | |
1016 for (size_t i = 0; i < arraysize(expected); ++i) { | |
1017 ASSERT_EQ(expected[i], | |
1018 ShellUtil::ByteArrayToBase32(test_array, i)); | |
1019 } | |
1020 } | |
OLD | NEW |