ReactOS  0.4.13-dev-249-gcba1a2f
CComQIPtr.cpp File Reference
#include <atlbase.h>
#include <atlcom.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
Include dependency graph for CComQIPtr.cpp:

Go to the source code of this file.

Classes

class  CQITestObject
 

Macros

#define ok(value, ...)   ok_func(__FILE__, __LINE__, value, __VA_ARGS__)
 
#define START_TEST(x)   int main(void)
 
#define DECLARE_QIPTR(type)   CComQIPtr<type>
 

Functions

void ok_func (const char *file, int line, BOOL value, const char *fmt,...)
 
 START_TEST (CComQIPtr)
 

Variables

int g_tests_executed = 0
 
int g_tests_failed = 0
 
static LONG g_QI = 0
 

Macro Definition Documentation

◆ DECLARE_QIPTR

#define DECLARE_QIPTR (   type)    CComQIPtr<type>

Definition at line 104 of file CComQIPtr.cpp.

◆ ok

#define ok (   value,
  ... 
)    ok_func(__FILE__, __LINE__, value, __VA_ARGS__)

Definition at line 33 of file CComQIPtr.cpp.

◆ START_TEST

#define START_TEST (   x)    int main(void)

Definition at line 34 of file CComQIPtr.cpp.

Function Documentation

◆ ok_func()

void ok_func ( const char file,
int  line,
BOOL  value,
const char fmt,
  ... 
)

Definition at line 19 of file CComQIPtr.cpp.

20  {
21  va_list va;
22  va_start(va, fmt);
23  if (!value)
24  {
25  printf("%s (%d): ", file, line);
26  vprintf(fmt, va);
28  }
30  va_end(va);
31  }
int g_tests_executed
Definition: CComQIPtr.cpp:17
#define va_end(ap)
Definition: acmsvcex.h:90
Definition: parser.c:48
char * va_list
Definition: acmsvcex.h:78
_Check_return_opt_ _CRTIMP int __cdecl vprintf(_In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
int g_tests_failed
Definition: CComQIPtr.cpp:18
#define va_start(ap, A)
Definition: acmsvcex.h:91
Definition: dsound.c:943
#define printf
Definition: config.h:203
Definition: fci.c:126

◆ START_TEST()

START_TEST ( CComQIPtr  )

Definition at line 107 of file CComQIPtr.cpp.

108 {
109  CQITestObject testObject;
110  IUnknown* unk = static_cast<IPersist*>(&testObject);
111  ok(testObject.m_dwRef == 1, "Expected m_dwRef 1, got %lu\n", testObject.m_dwRef);
112  ok(g_QI == 0, "Expected g_QI 0, got %lu\n", g_QI);
113 
114  {
115  DECLARE_QIPTR(IPersist) ppPersist(unk);
116  ok(testObject.m_dwRef == 2, "Expected m_dwRef 2, got %lu\n", testObject.m_dwRef);
117  ok(g_QI == 1, "Expected g_QI 1, got %lu\n", g_QI);
118 
119  DECLARE_QIPTR(IStdMarshalInfo) ppMarshal(ppPersist);
120  ok(testObject.m_dwRef == 3, "Expected m_dwRef 3, got %lu\n", testObject.m_dwRef);
121  ok(g_QI == 2, "Expected g_QI 2, got %lu\n", g_QI);
122  }
123  ok(testObject.m_dwRef == 1, "Expected m_dwRef 1, got %lu\n", testObject.m_dwRef);
124  {
125  DECLARE_QIPTR(IStdMarshalInfo) ppMarshal;
126  ok(testObject.m_dwRef == 1, "Expected m_dwRef 1, got %lu\n", testObject.m_dwRef);
127  ok(g_QI == 2, "Expected g_QI 2, got %lu\n", g_QI);
128 
129  ppMarshal = unk;
130  ok(testObject.m_dwRef == 2, "Expected m_dwRef 2, got %lu\n", testObject.m_dwRef);
131  ok(g_QI == 3, "Expected g_QI 3, got %lu\n", g_QI);
132 
133  ppMarshal = static_cast<IUnknown*>(NULL);
134  ok(testObject.m_dwRef == 1, "Expected m_dwRef 1, got %lu\n", testObject.m_dwRef);
135  ok(g_QI == 3, "Expected g_QI 3, got %lu\n", g_QI);
136 
137  CComPtr<IUnknown> spUnk(unk);
138  ok(testObject.m_dwRef == 2, "Expected m_dwRef 2, got %lu\n", testObject.m_dwRef);
139  ok(g_QI == 3, "Expected g_QI 3, got %lu\n", g_QI);
140 
141  ppMarshal = spUnk;
142  ok(testObject.m_dwRef == 3, "Expected m_dwRef 3, got %lu\n", testObject.m_dwRef);
143  ok(g_QI == 4, "Expected g_QI 4, got %lu\n", g_QI);
144 
145  spUnk.Release();
146  ok(testObject.m_dwRef == 2, "Expected m_dwRef 2, got %lu\n", testObject.m_dwRef);
147  ok(g_QI == 4, "Expected g_QI 4, got %lu\n", g_QI);
148 
149  spUnk = ppMarshal;
150  ok(testObject.m_dwRef == 3, "Expected m_dwRef 3, got %lu\n", testObject.m_dwRef);
151 #ifdef __REACTOS__
152  // CORE-12710
153  todo_if(1)
154 #endif
155  ok(g_QI == 5, "Expected g_QI 5, got %lu\n", g_QI);
156  }
157 
158 #ifndef HAVE_APITEST
159  printf("CComQIPtr: %i tests executed (0 marked as todo, %i failures), 0 skipped.\n", g_tests_executed, g_tests_failed);
160  return g_tests_failed;
161 #endif
162 }
int g_tests_executed
Definition: CComQIPtr.cpp:17
smooth NULL
Definition: ftsmooth.c:416
#define DECLARE_QIPTR(type)
Definition: CComQIPtr.cpp:104
static LONG g_QI
Definition: CComQIPtr.cpp:38
int g_tests_failed
Definition: CComQIPtr.cpp:18
#define todo_if(is_todo)
Definition: test.h:144
#define ok(value,...)
Definition: CComQIPtr.cpp:33
#define printf
Definition: config.h:203

Variable Documentation

◆ g_QI

LONG g_QI = 0
static

Definition at line 38 of file CComQIPtr.cpp.

Referenced by CQITestObject::QueryInterface(), and START_TEST().

◆ g_tests_executed

int g_tests_executed = 0

Definition at line 17 of file CComQIPtr.cpp.

Referenced by ok_func(), and START_TEST().

◆ g_tests_failed

int g_tests_failed = 0

Definition at line 18 of file CComQIPtr.cpp.

Referenced by ok_func(), and START_TEST().