File: bridge.m

package info (click to toggle)
gnustep-corebase 0.1.1%2B20230710-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,608 kB
  • sloc: ansic: 25,359; objc: 4,347; cpp: 75; xml: 49; makefile: 24; sh: 7
file content (71 lines) | stat: -rw-r--r-- 2,084 bytes parent folder | download
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
69
70
71
#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSTimeZone.h>
#include "CoreFoundation/CFTimeZone.h"
#include "../CFTesting.h"

void testNSonCF(void);
void testCFonNS(void);

int main(void)
{
  ENTER_POOL
  testNSonCF();
  testCFonNS();
  LEAVE_POOL
  return 0;
}

void testNSonCF(void)
{
  CFTimeZoneRef cftz = CFTimeZoneCopySystem();
  NSTimeZone* nstz = (NSTimeZone*) cftz;
  CFStringRef abbrev;

  PASS_CFEQ(CFTimeZoneGetName(cftz), [nstz name],
    "-name works on a CFTimeZone");
  PASS_CF(CFTimeZoneGetSecondsFromGMT(cftz, CFAbsoluteTimeGetCurrent()) == [nstz secondsFromGMT],
    "-secondsFromGMT works on a CFTimeZone");
  
  // TODO: this test is not "stable" enough
  PASS_CF(CFTimeZoneIsDaylightSavingTime(cftz, CFAbsoluteTimeGetCurrent()) == [nstz isDaylightSavingTime],
    "-isDaylightSavingTime works on a CFTimeZone");
  
  abbrev = CFTimeZoneCopyAbbreviation(cftz, CFAbsoluteTimeGetCurrent());
  PASS_CFEQ(abbrev, [nstz abbreviation],
    "-abbreviation works on a CFTimeZone");
  CFRelease(abbrev);
    
  // TODO: test other functions
  
  [nstz release];
}

void testCFonNS(void)
{
  NSTimeZone* nstz = [NSTimeZone systemTimeZone];
  CFTimeZoneRef cftz = (CFTimeZoneRef) nstz;
  CFStringRef abbrev;
  
  PASS_CFEQ([nstz name], CFTimeZoneGetName(cftz),
    "CFTimeZoneGetName() works on an NSTimeZone");
#if __arm__ && __ARM_EABI__ && __ARM_PCS_VFP
  testHopeful = true;
#endif
  PASS_CF(CFTimeZoneGetSecondsFromGMT(cftz, CFAbsoluteTimeGetCurrent()) == [nstz secondsFromGMT],
    "CFTimeZoneGetSecondsFromGMT works on an NSTimeZone");
#if __arm__ && __ARM_EABI__ && __ARM_PCS_VFP
  testHopeful = false;
#endif
  
  // TODO: this test is not "stable" enough
  PASS_CF(CFTimeZoneIsDaylightSavingTime(cftz, CFAbsoluteTimeGetCurrent()) == [nstz isDaylightSavingTime],
    "CFTimeZoneIsDaylightSavingTime() works on an NSTimeZone");
  
#if !__sparc__
  abbrev = CFTimeZoneCopyAbbreviation(cftz, CFAbsoluteTimeGetCurrent());
  PASS_CFEQ([nstz abbreviation], abbrev,
    "CFTimeZoneCopyAbbreviation() works on an NSTimeZone");
  CFRelease(abbrev);
#endif
}