summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/file_io/CompareFileTime/test1/CompareFileTime.c
blob: 3758f7e4eb777368d27a66e8a05b3aaceba9cf42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

/*=====================================================================
**
** Source:  CompareFileTime.c
**
** Purpose: Tests the PAL implementation of the CompareFileTime function.
** Defines a large and small file time, and compares them in all fashions
** to ensure proper return values.
**
**
**===================================================================*/

#include <palsuite.h>



int __cdecl main(int argc, char **argv)
{

    FILETIME SmallTime, BigTime;

    if (0 != PAL_Initialize(argc,argv))
    {
        return FAIL;
    }

    /* Set a Big and Small time.  These were generated using
       GetFileTime on a file, with a recent creation time and an old
       modify time, to get a bigger and smaller value.
    */
    
    BigTime.dwLowDateTime = -755748832;
    BigTime.dwHighDateTime = 29436941;

    SmallTime.dwLowDateTime = -459754240;
    SmallTime.dwHighDateTime = 29436314;

    /* Check to see that SmallTime is less than Big Time */

    if(CompareFileTime(&SmallTime,&BigTime) != -1)
    {
        Fail("ERROR: The first time is less than the second time, so "
               "-1 should have been returned to indicate this.");
    }

    /* Check that BigTime is greater than SmallTime */

    if(CompareFileTime(&BigTime,&SmallTime) != 1)
    {
        Fail("ERROR: The first time is greater than the second time, so "
               "1 should have been returned to indicate this.");
    }

    /* Check that BigTime is equal to BigTime */

    if(CompareFileTime(&BigTime,&BigTime) != 0)
    {
        Fail("ERROR: The first time is equal to the second time, so "
               "0 should have been returned to indicate this.");
    }
    
    PAL_Terminate();
    return PASS;
}