blob: 00facfbb88d1efc9ce639b89d7016ba53d4d49ae [file] [log] [blame]
Jonas Oreland1cd39fa2018-10-11 07:47:12 +02001/*
2 * Copyright 2018 The WebRTC Project Authors. All rights reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#include <memory>
12#include <string>
13#include <vector>
14
15#include "p2p/base/icecredentialsiterator.h"
16#include "rtc_base/gunit.h"
17
18using cricket::IceParameters;
19using cricket::IceCredentialsIterator;
20
21TEST(IceCredentialsIteratorTest, GetEmpty) {
22 std::vector<IceParameters> empty;
23 IceCredentialsIterator iterator(empty);
24 // Verify that we can get credentials even if input is empty.
25 IceParameters credentials1 = iterator.GetIceCredentials();
26}
27
28TEST(IceCredentialsIteratorTest, GetOne) {
29 std::vector<IceParameters> one = {
30 IceCredentialsIterator::CreateRandomIceCredentials()};
31 IceCredentialsIterator iterator(one);
32 EXPECT_EQ(iterator.GetIceCredentials(), one[0]);
33 auto random = iterator.GetIceCredentials();
34 EXPECT_NE(random, one[0]);
35 EXPECT_NE(random, iterator.GetIceCredentials());
36}
37
38TEST(IceCredentialsIteratorTest, GetTwo) {
39 std::vector<IceParameters> two = {
40 IceCredentialsIterator::CreateRandomIceCredentials(),
41 IceCredentialsIterator::CreateRandomIceCredentials()};
42 IceCredentialsIterator iterator(two);
43 EXPECT_EQ(iterator.GetIceCredentials(), two[1]);
44 EXPECT_EQ(iterator.GetIceCredentials(), two[0]);
45 auto random = iterator.GetIceCredentials();
46 EXPECT_NE(random, two[0]);
47 EXPECT_NE(random, two[1]);
48 EXPECT_NE(random, iterator.GetIceCredentials());
49}