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