kernel32: Update function docs for GetBinayType.
[wine] / dlls / wer / tests / main.c
1 /*
2  * Unit test suite for windows error reporting in Vista and above
3  *
4  * Copyright 2010 Detlef Riekenberg
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  *
20  */
21
22 #include <stdarg.h>
23 #include <stdio.h>
24
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winerror.h"
28 #include "winreg.h"
29
30 #include "werapi.h"
31 #include "wine/test.h"
32
33 static const WCHAR empty[] = {0};
34 static const WCHAR winetest_wer[] = {'w','i','n','e','t','e','s','t','_','w','e','r','.','e','x','e',0};
35
36 /* ###### */
37
38 static void test_WerAddExcludedApplication(void)
39 {
40     HRESULT hr;
41
42     /* clean state */
43     hr = WerRemoveExcludedApplication(winetest_wer, FALSE);
44     if (hr == E_NOTIMPL) {
45         skip("Wer*ExcludedApplication not implemented\n");
46         return;
47     }
48     ok((hr == S_OK) || (hr == E_FAIL) || __HRESULT_FROM_WIN32(ERROR_ENVVAR_NOT_FOUND),
49         "got 0x%x (expected S_OK, E_FAIL or HRESULT_FROM_WIN32(ERROR_ENVVAR_NOT_FOUND))\n", hr);
50
51     hr = WerAddExcludedApplication(NULL, FALSE);
52     ok(hr == E_INVALIDARG, "got 0x%x (expected E_INVALIDARG)\n", hr);
53
54     hr = WerAddExcludedApplication(empty, FALSE);
55     ok(hr == E_INVALIDARG, "got 0x%x (expected E_INVALIDARG)\n", hr);
56
57     hr = WerAddExcludedApplication(winetest_wer, FALSE);
58     ok(hr == S_OK, "got 0x%x (expected S_OK)\n", hr);
59     /* app already in the list */
60     hr = WerAddExcludedApplication(winetest_wer, FALSE);
61     ok(hr == S_OK, "got 0x%x (expected S_OK)\n", hr);
62
63
64     /* cleanup */
65     hr = WerRemoveExcludedApplication(winetest_wer, FALSE);
66     ok(hr == S_OK, "got 0x%x (expected S_OK)\n", hr);
67 }
68
69 /* #### */
70
71 static void test_WerRemoveExcludedApplication(void)
72 {
73     HRESULT hr;
74
75     /* clean state */
76     hr = WerRemoveExcludedApplication(winetest_wer, FALSE);
77     if (hr == E_NOTIMPL) {
78         skip("Wer*ExcludedApplication not implemented\n");
79         return;
80     }
81
82     ok((hr == S_OK) || (hr == E_FAIL) || __HRESULT_FROM_WIN32(ERROR_ENVVAR_NOT_FOUND),
83         "got 0x%x (expected S_OK, E_FAIL or HRESULT_FROM_WIN32(ERROR_ENVVAR_NOT_FOUND))\n", hr);
84
85     hr = WerAddExcludedApplication(winetest_wer, FALSE);
86     ok(hr == S_OK, "got 0x%x (expected S_OK)\n", hr);
87
88     hr = WerRemoveExcludedApplication(NULL, FALSE);
89     ok(hr == E_INVALIDARG, "got 0x%x (expected E_INVALIDARG)\n", hr);
90
91     hr = WerRemoveExcludedApplication(empty, FALSE);
92     ok(hr == E_INVALIDARG, "got 0x%x (expected E_INVALIDARG)\n", hr);
93
94     hr = WerRemoveExcludedApplication(winetest_wer, FALSE);
95     ok(hr == S_OK, "got 0x%x (expected S_OK)\n", hr);
96
97     /* app not in the list */
98     hr = WerRemoveExcludedApplication(winetest_wer, FALSE);
99     ok((hr == E_FAIL) || __HRESULT_FROM_WIN32(ERROR_ENVVAR_NOT_FOUND),
100         "got 0x%x (expected E_FAIL or HRESULT_FROM_WIN32(ERROR_ENVVAR_NOT_FOUND))\n", hr);
101
102 }
103
104 /* ########################### */
105
106 START_TEST(main)
107 {
108     test_WerAddExcludedApplication();
109     test_WerRemoveExcludedApplication();
110 }