Skip to content

Commit b3d037e

Browse files
committed
Added Semaphore unit test
1 parent 963c12f commit b3d037e

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

src/unit_test/TestSemaphore.cpp

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
#include "gtest/gtest.h"
3+
#include "OSS/Semaphore.h"
4+
5+
using namespace OSS;
6+
7+
8+
TEST(ThreadTest, test_counting_semaphore_basic)
9+
{
10+
Semaphore sem0;
11+
12+
for (int i = 0; i < 1000000; i++)
13+
sem0.signal();
14+
15+
for (int i = 0; i < 1000000; i++)
16+
ASSERT_TRUE(sem0.wait(0));
17+
18+
for (int i = 0; i < 500; i++)
19+
sem0.signal();
20+
21+
for (int i = 0; i < 500; i++)
22+
ASSERT_TRUE(sem0.wait(100));
23+
24+
for (int i = 0; i < 500; i++)
25+
ASSERT_FALSE(sem0.wait(0));
26+
27+
for (int i = 0; i < 500; i++)
28+
sem0.signal();
29+
30+
for (int i = 0; i < 500; i++)
31+
ASSERT_TRUE(sem0.wait(-100));
32+
33+
for (int i = 0; i < 500; i++)
34+
sem0.signal();
35+
36+
for (int i = 0; i < 500; i++)
37+
sem0.wait();
38+
}

src/unit_test/TestWebSocket.cpp

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (C) 2012 OSS Software Solutions
3+
*
4+
* This program is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU Lesser General Public
6+
* License as published by the Free Software Foundation; either
7+
* version 2.1 of the License, or (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
* Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public
15+
* License along with main.c; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
17+
*/
18+
19+
20+
21+
#include "gtest/gtest.h"
22+
#include "OSS/SIP/SIPWebSocketListener.h"
23+
24+
using namespace OSS;
25+
using namespace OSS::SIP;
26+
27+
TEST(SipTransportTest, test_websocket_listen)
28+
{
29+
#if 0
30+
SIPWebSocketConnectionManager manager(NULL);
31+
SIPWebSocketListener listener(NULL, "127.0.0.1", "18080", manager);
32+
listener.run();
33+
OSS::thread_sleep(1000);
34+
#endif
35+
}

0 commit comments

Comments
 (0)