My favorites | Sign in
Project Logo
                
Changes to /branches/2.2/Tests/ProxyTest.m
r0 vs. r513   Edit
  Compare: vs.   Format:
Revision r513
Go to: 
Sign in to write a code review
/branches/2.2/Tests/ProxyTest.m   r0 /branches/2.2/Tests/ProxyTest.m   r513
  1 //
  2 // Proxy.m
  3 // JSON
  4 //
  5 // Created by Stig Brautaset on 25/05/2009.
  6 // Copyright 2009 Morgan Stanley. All rights reserved.
  7 //
  8
  9 #import "ProxyTest.h"
  10 #import "JSON.h"
  11
  12 @interface True : NSObject
  13 @end
  14
  15 @implementation True
  16 - (id)jsonRepresentationProxy {
  17 return [NSNumber numberWithBool:YES];
  18 }
  19 @end
  20
  21 @interface False : NSObject
  22 @end
  23
  24 @implementation False
  25 - (id)jsonRepresentationProxy {
  26 return [NSNumber numberWithBool:NO];
  27 }
  28 @end
  29
  30
  31 @interface Bool : NSObject
  32 @end
  33
  34 @implementation Bool
  35 - (id)jsonRepresentationProxy {
  36 return [NSArray arrayWithObjects:[True new], [False new], nil];
  37 }
  38 @end
  39
  40 @implementation ProxyTest
  41
  42 - (void)setUp {
  43 writer = [SBJsonWriter new];
  44 }
  45
  46 - (void)testUnsupportedWithoutProxy {
  47 STAssertNil([writer stringWithObject:[NSArray arrayWithObject:[NSObject new]]], nil);
  48 STAssertEquals([[writer.errorTrace objectAtIndex:0] code], (NSInteger)EUNSUPPORTED, nil);
  49 }
  50
  51 - (void)testUnsupportedWithProxy {
  52 STAssertEqualObjects([writer stringWithObject:[NSArray arrayWithObject:[True new]]], @"[true]", nil);
  53 }
  54
  55 - (void)testUnsupportedWithNestedProxy {
  56 STAssertEqualObjects([writer stringWithObject:[NSArray arrayWithObject:[Bool new]]], @"[[true,false]]", nil);
  57 }
  58
  59 @end
Hosted by Google Code