/[jscoverage]/trunk/tests/streams.c
ViewVC logotype

Diff of /trunk/tests/streams.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 111 by siliconforks, Wed May 7 04:23:44 2008 UTC revision 112 by siliconforks, Sat May 31 21:21:59 2008 UTC
# Line 38  Line 38 
38    assert(memcmp(stream->data, "abc 123\n", 8) == 0);    assert(memcmp(stream->data, "abc 123\n", 8) == 0);
39    Stream_delete(stream);    Stream_delete(stream);
40    
41      stream = Stream_new(10);
42      size_t length = 0;
43      for (int i = 0; i < 100; i++) {
44        Stream_printf(stream, "%s %d\n", "abc", i);
45        if (i < 10) {
46          length += 6;
47        }
48        else {
49          length += 7;
50        }
51      }
52      assert(stream->length == length);
53      length = 0;
54      for (int i = 0; i < 100; i++) {
55        char buffer[8];
56        int result = sprintf(buffer, "%s %d\n", "abc", i);
57        assert(memcmp(stream->data + length, buffer, result) == 0);
58        length += result;
59      }
60      assert(stream->length == length);
61      Stream_delete(stream);
62    
63      stream = Stream_new(10);
64      char buffer[100];
65      for (int i = 0; i < 100; i++) {
66        buffer[i] = 'x';
67      }
68      Stream_write(stream, buffer, 100);
69      assert(stream->length == 100);
70      for (int i = 0; i < 100; i++) {
71        assert(stream->data[i] == 'x');
72      }
73      Stream_delete(stream);
74    
75    exit(EXIT_SUCCESS);    exit(EXIT_SUCCESS);
76  }  }

Legend:
Removed from v.111  
changed lines
  Added in v.112

  ViewVC Help
Powered by ViewVC 1.1.24