Project: engagement_recognition License: BSD Dependencies:
Used by:
None |
engagement_recognition/test/statistics/connection_event_test.cppGo to the documentation of this file.00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2010, Worcester Polytechnic Institute 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * * Redistributions in binary form must reproduce the above 00014 * copyright notice, this list of conditions and the following 00015 * disclaimer in the documentation and/or other materials provided 00016 * with the distribution. 00017 * * Neither the name of Worcester Polytechnic Institute. nor the names 00018 * of its contributors may be used to endorse or promote products 00019 * derived from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00022 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00023 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00024 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00025 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00026 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00027 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00028 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00031 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00032 * POSSIBILITY OF SUCH DAMAGE. 00033 */ 00034 #include <gtest/gtest.h> 00035 00036 #include <string> 00037 #include "../src/recognition/lib/engagement_macros.h" 00038 #include "../src/recognition/statistics/connection_event.h" 00039 00043 TEST(ConnectionEventTestSuite, testConstructor) 00044 { 00045 // Try a DG event 00046 std::string type = "DG"; 00047 bool success = true; 00048 long start = CURRENT_TIME; 00049 long delay = 1000; 00050 long duration = 5000; 00051 00052 ConnectionEvent event = ConnectionEvent(type, success, 00053 start, delay, 00054 duration); 00055 00056 // Make sure everything is equal 00057 EXPECT_EQ(type, event.getType()); 00058 EXPECT_EQ(success, event.getSuccess()); 00059 EXPECT_EQ(start, event.getStart()); 00060 EXPECT_EQ(delay, event.getDelay()); 00061 EXPECT_EQ(duration, event.getDuration()); 00062 00063 // Try an MFG event 00064 type = "MFG"; 00065 success = false; 00066 start = 0; 00067 delay = 0; 00068 duration = 0; 00069 00070 event = ConnectionEvent(type, success, start, delay, duration); 00071 00072 // Make sure everything is equal 00073 EXPECT_EQ(type, event.getType()); 00074 EXPECT_EQ(success, event.getSuccess()); 00075 EXPECT_EQ(start, event.getStart()); 00076 EXPECT_EQ(delay, event.getDelay()); 00077 EXPECT_EQ(duration, event.getDuration()); 00078 00079 // Try an BC event 00080 type = "BC"; 00081 success = false; 00082 start = CURRENT_TIME; 00083 delay = -1000; 00084 duration = -1000; 00085 00086 event = ConnectionEvent(type, success, start, delay, duration); 00087 00088 // Make sure everything is equal 00089 EXPECT_EQ(type, event.getType()); 00090 EXPECT_EQ(success, event.getSuccess()); 00091 EXPECT_EQ(start, event.getStart()); 00092 EXPECT_EQ(delay, event.getDelay()); 00093 EXPECT_EQ(duration, event.getDuration()); 00094 00095 // Try an AP event 00096 type = "AP"; 00097 success = true; 00098 start = -1001; 00099 delay = 99999; 00100 duration = -99999; 00101 00102 event = ConnectionEvent(type, success, start, delay, duration); 00103 00104 // Make sure everything is equal 00105 EXPECT_EQ(type, event.getType()); 00106 EXPECT_EQ(success, event.getSuccess()); 00107 EXPECT_EQ(start, event.getStart()); 00108 EXPECT_EQ(delay, event.getDelay()); 00109 EXPECT_EQ(duration, event.getDuration()); 00110 } |