Home | History | Annotate | Download | only in source
      1 /*
      2  *  Copyright (c) 2011 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 <string>
     12 
     13 #include "data_log.h"
     14 #include "gtest/gtest.h"
     15 
     16 using ::webrtc::DataLog;
     17 
     18 TEST(TestDataLog, IntContainers) {
     19   int c = 5;
     20   webrtc::ValueContainer<int> v1(c);
     21   c = 10;
     22   webrtc::ValueContainer<int> v2(c);
     23   std::string s1, s2;
     24   v1.ToString(&s1);
     25   v2.ToString(&s2);
     26   ASSERT_EQ(s1, "5,");
     27   ASSERT_EQ(s2, "10,");
     28   v1 = v2;
     29   v1.ToString(&s1);
     30   ASSERT_EQ(s1, s2);
     31 }
     32 
     33 TEST(TestDataLog, DoubleContainers) {
     34   double c = 3.5;
     35   webrtc::ValueContainer<double> v1(c);
     36   c = 10.3;
     37   webrtc::ValueContainer<double> v2(c);
     38   std::string s1, s2;
     39   v1.ToString(&s1);
     40   v2.ToString(&s2);
     41   ASSERT_EQ(s1, "3.5,");
     42   ASSERT_EQ(s2, "10.3,");
     43   v1 = v2;
     44   v1.ToString(&s1);
     45   ASSERT_EQ(s1, s2);
     46 }
     47 
     48 TEST(TestDataLog, MultiValueContainers) {
     49   int a[3] = {1, 2, 3};
     50   int b[3] = {4, 5, 6};
     51   webrtc::MultiValueContainer<int> m1(a, 3);
     52   webrtc::MultiValueContainer<int> m2(b, 3);
     53   webrtc::MultiValueContainer<int> m3(a, 3);
     54   std::string s1, s2, s3;
     55   m1.ToString(&s1);
     56   m2.ToString(&s2);
     57   ASSERT_EQ(s1, "1,2,3,");
     58   ASSERT_EQ(s2, "4,5,6,");
     59   m1 = m2;
     60   m1.ToString(&s1);
     61   ASSERT_EQ(s1, s2);
     62   m3.ToString(&s3);
     63   ASSERT_EQ(s3, "1,2,3,");
     64 }
     65