2 * Copyright 2016 Jared Smudde
4 * This library 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.
9 * This library 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.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 /* Documentation: https://msdn.microsoft.com/en-us/library/windows/desktop/aa366197%28v=vs.85%29.aspx */
23 static BOOL (WINAPI
*pNcIsValidConnectionName
)(PCWSTR
);
25 #define CALL_NC(exp, str) \
27 BOOL ret = pNcIsValidConnectionName((str)); \
28 ok(ret == (exp), "Expected %s to be %d, was %d\n", wine_dbgstr_w((str)), (exp), ret); \
33 static void test_BadLetters(void)
40 for (i
= 1; i
<= 0xFFFF; ++i
)
43 buf
[1] = buf
[2] = L
'\0';
45 if (wcspbrk(buf
, L
"\\/:\t*? <>|\"") != NULL
)
47 ret
= pNcIsValidConnectionName(buf
);
48 ok(ret
== FALSE
, "Expected %s (%i) to fail.\n", wine_dbgstr_w(buf
), i
);
50 /* How about two of a kind? */
52 ret
= pNcIsValidConnectionName(buf
);
53 ok(ret
== FALSE
, "Expected %s (%i) to fail.\n", wine_dbgstr_w(buf
), i
);
55 /* And something (bad) combined with a space? */
57 ret
= pNcIsValidConnectionName(buf
);
58 ok(ret
== FALSE
, "Expected %s (%i) to fail.\n", wine_dbgstr_w(buf
), i
);
61 /* Something bad combined with a letter */
63 ret
= pNcIsValidConnectionName(buf
);
65 ok(ret
== TRUE
, "Expected %s (%i) to succeed.\n", wine_dbgstr_w(buf
), i
);
67 ok(ret
== FALSE
, "Expected %s (%i) to fail.\n", wine_dbgstr_w(buf
), i
);
71 ret
= pNcIsValidConnectionName(buf
);
72 ok(ret
== TRUE
, "Expected %s (%i) to succeed.\n", wine_dbgstr_w(buf
), i
);
75 ret
= pNcIsValidConnectionName(buf
);
76 ok(ret
== TRUE
, "Expected %s (%i) to succeed.\n", wine_dbgstr_w(buf
), i
);
79 ret
= pNcIsValidConnectionName(buf
);
80 ok(ret
== TRUE
, "Expected %s (%i) to succeed.\n", wine_dbgstr_w(buf
), i
);
83 ret
= pNcIsValidConnectionName(buf
);
84 ok(ret
== TRUE
, "Expected %s (%i) to succeed.\n", wine_dbgstr_w(buf
), i
);
89 START_TEST(isvalidname
)
91 HMODULE hDll
= LoadLibraryA("netshell.dll");
93 pNcIsValidConnectionName
= (void*)GetProcAddress(hDll
, "NcIsValidConnectionName");
94 if (!hDll
|| !pNcIsValidConnectionName
)
96 skip("netshell.dll or export NcIsValidConnectionName not found! Tests will be skipped\n");
100 CALL_NC(TRUE
, L
"Network");
101 CALL_NC(FALSE
, L
"Network?");
103 CALL_NC(FALSE
, L
"\\");
104 CALL_NC(FALSE
, L
"/");
105 CALL_NC(FALSE
, L
":");
106 CALL_NC(FALSE
, L
"*");
107 CALL_NC(FALSE
, L
"?");
108 CALL_NC(FALSE
, L
"<");
109 CALL_NC(FALSE
, L
">");
110 CALL_NC(FALSE
, L
"|");
112 CALL_NC(FALSE
, NULL
);
114 CALL_NC(TRUE
, L
"Wireless");
115 CALL_NC(FALSE
, L
"Wireless:1");
116 CALL_NC(TRUE
, L
"Intranet");
117 CALL_NC(FALSE
, L
"Intranet<");
118 CALL_NC(TRUE
, L
"Network Connection");