Annotation of objc/Test/StringTableTest.m, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      6:  * "Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
                      7:  * Reserved.  This file contains Original Code and/or Modifications of
                      8:  * Original Code as defined in and that are subject to the Apple Public
                      9:  * Source License Version 1.0 (the 'License').  You may not use this file
                     10:  * except in compliance with the License.  Please obtain a copy of the
                     11:  * License at http://www.apple.com/publicsource and read it before using
                     12:  * this file.
                     13:  * 
                     14:  * The Original Code and all software distributed under the License are
                     15:  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
                     16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
                     17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
                     18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
                     19:  * License for the specific language governing rights and limitations
                     20:  * under the License."
                     21:  * 
                     22:  * @APPLE_LICENSE_HEADER_END@
                     23:  */
                     24: 
                     25: #include <libc.h>
                     26: #include <stdio.h>
                     27: #include <stdlib.h>
                     28: #include <objc/NXStringTable.h>
                     29: 
                     30: /* Tests to make sure that the lexer in NXStringTable.m is identical to
                     31:    the compiler's lexer. */
                     32: 
                     33: const char s1[] = "hello world";
                     34: const char s2[] = "\'\"\?\\\a\b\f\n\r\t\v";
                     35: const char s3[] = "\1234q\123q\12q\1q";
                     36: const char s4[] = "\xffq\xfq";
                     37: const char s5[] = "\q\8q";     /* error cases */
                     38: 
                     39: int main (void)
                     40: {
                     41:   NXStringTable *table = [[NXStringTable alloc] init];
                     42:   
                     43:   [table readFromFile: "test.strings"];
                     44:   
                     45:   if ([table valueForStringKey: s1] == NULL ||
                     46:       [table valueForStringKey: s2] == NULL ||
                     47:       [table valueForStringKey: s3] == NULL ||
                     48:       [table valueForStringKey: s4] == NULL ||
                     49:       [table valueForStringKey: s5] == NULL)
                     50:     {
                     51:       fprintf (stderr, "failed\n");
                     52:       return EXIT_FAILURE;
                     53:     }
                     54:   
                     55:   [table writeToFile: "test2.strings"];
                     56:   
                     57:   [table readFromFile: "test2.strings"];
                     58:   
                     59:   if ([table valueForStringKey: s1] == NULL ||
                     60:       [table valueForStringKey: s2] == NULL ||
                     61:       [table valueForStringKey: s3] == NULL ||
                     62:       [table valueForStringKey: s4] == NULL ||
                     63:       [table valueForStringKey: s5] == NULL)
                     64:     {
                     65:       fprintf (stderr, "failed\n");
                     66:       return EXIT_FAILURE;
                     67:     }
                     68:   
                     69:   fprintf (stderr, "passed\n");
                     70:   return EXIT_SUCCESS;
                     71: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.