Merge pull request #4938 from kumpera/optimize_ref_queries
[mono.git] / mono / tests / w32message.cs
1 //
2 // This test merely creates a Win32Exception that triggers the
3 // code in mono/io-layer/message.c that validates that the
4 // error table is propertly sorted
5 using System;
6 using System.ComponentModel;
7
8 class X {
9         static string msg (int c)
10         {
11                 return new Win32Exception (c).Message;
12         }
13
14         static bool check (int c, string s)
15         {
16                 if (msg (c) != s) {
17                         Console.Error.WriteLine ("For {0} expected {1} got {2}", c, s, msg (c));
18                         return false;
19                 }
20                 return true;
21         }
22         
23         static int Main ()
24         {
25                 //
26                 // All this test does is instantiate two Win32Exceptions
27                 // one with no known text, so it triggers a linear search
28                 // And one with a known message, to trigger a validation
29                 //
30                 // If stderr gets any output, there is a sorting error
31                 // in mono/io-layer/messages.c
32                 //
33                 Exception a = new Win32Exception (99999);
34                 a = new Win32Exception (9805);
35
36                 if (!check (2, "Cannot find the specified file"))
37                         return 1;
38
39
40                 return 0;
41         }
42         
43 }