Revision 1225

branches/threaded2merge/tests/GNUmakefile (revision 1225)
2 2

  
3 3
GTEST_DIR=googletest-read-only
4 4

  
5
all: $(GTEST_DIR)/gtest-all.o msimple
6

  
5 7
ifneq ($(CXX),CC)
6 8
all: $(GTEST_DIR)/gtest-all.o test-threads gtests
7 9
else
......
28 30
googletest-read-only:
29 31
	svn checkout http://googletest.googlecode.com/svn/trunk/ googletest-read-only
30 32

  
33
msimple:
34
	$(MAKE) --directory=threads/msimple
35

  
31 36
test-threads:
32 37
	$(MAKE) --directory=threads clean
33
	$(MAKE) --directory=threads
38
	$(MAKE) --directory=threads/msimple
34 39

  
35 40
svn: svn-geolocation
36 41

  
branches/threaded2merge/tests/threads/msimple/GNUmakefile (revision 1225)
5 5
msimple.cpp: msimple.tpl
6 6
	../../../admb -g msimple
7 7

  
8
tests_msimple: msimple.cpp tests_msimple.cpp
8
tests_msimple: msimple.cpp tests_msimple.cpp tests_adthread_manager.cpp
9 9
	cp $(GTEST_DIR)/gtest-all.o .
10
	CXXFLAGS="-I$(GTEST_DIR)/include" ../../../admb -g tests_msimple.cpp main.cpp gtest-all.o
10
	CXXFLAGS="-I$(GTEST_DIR)/include" ../../../admb -g tests_msimple.cpp tests_adthread_manager.cpp main.cpp gtest-all.o
11 11

  
12 12
run: tests_msimple
13 13
	-./tests_msimple
branches/threaded2merge/tests/threads/msimple/tests_adthread_manager.cpp (revision 1225)
1
#include <gtest/gtest.h>
2
#include <fvar.hpp>
3
#include <adthread.h>
4

  
5
class tests_adthread_manager: public ::testing::Test {};
6

  
7
TEST_F(tests_adthread_manager, constructor)
8
{
9
  int nthread = 1;
10
  int ngroups = 1;
11
  ivector ng(1, ngroups);
12
  // number of threads in group 1
13
  ng(1)=nthread;
14
  // create instance of pthread_manager class 
15
  // third argument is number of bytes in the transfer buffer
16
  ad_comm::pthread_manager = new adpthread_manager(ngroups, ng, 32005);
17
  if (ad_comm::pthread_manager == 0)
18
  {
19
    FAIL();
20
  }
21
  delete ad_comm::pthread_manager;
22
  ad_comm::pthread_manager = 0;
23
}
24

  
25
static int test_attach_code_value = 0;
26
void* test_attach_code(void* ptr)
27
{
28
  test_attach_code_value = 1;
29
  return ptr;
30
}
31
TEST_F(tests_adthread_manager, attach_code)
32
{
33
  int nthread = 1;
34
  int ngroups = 1;
35
  ivector ng(1, ngroups);
36
  // number of threads in group 1
37
  ng(1)=nthread;
38
  // create instance of pthread_manager class 
39
  // third argument is number of bytes in the transfer buffer
40
  ad_comm::pthread_manager = new adpthread_manager(ngroups, ng, 32005);
41
  if (ad_comm::pthread_manager == 0)
42
  {
43
    FAIL();
44
  }
45

  
46
  ASSERT_EQ(0, test_attach_code_value);
47
  ad_comm::pthread_manager->attach_code(test_attach_code);
48
  ASSERT_EQ(0, test_attach_code_value);
49

  
50
  delete ad_comm::pthread_manager;
51
  ad_comm::pthread_manager = 0;
52
}
53
TEST_F(tests_adthread_manager, create_all)
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff