File: NSString_zero_hash.m

package info (click to toggle)
gnustep-base 1.31.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 26,580 kB
  • sloc: objc: 239,446; ansic: 36,519; cpp: 122; sh: 112; makefile: 100; xml: 32
file content (41 lines) | stat: -rw-r--r-- 731 bytes parent folder | download | duplicates (2)
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
/*
copyright 2004 Alexander Malmberg <alexander@malmberg.org>
*/

#import "Testing.h"

#import <Foundation/NSString.h>

int main(int argc, char **argv)
{
  START_SET("zero hash")
  NSString *s = @"!)9\" ;";
  unsigned int h;

/*
  Generate a (hopefully ASCII printable) string with a given hash.

  h = 0x50000000;
  while (h > 0)
    {
      int a,b;

      a = h/33;
      b = h%33;
      if (a)
	while (b < 32)
	  a--, b += 33;
      printf("%10i = %10i * 33 + %3i '%c'\n",h,a,b,b);
      h = a;
    }*/

  h = [s hash];
  PASS(h != 0, "[NSConstantString hash] does not return 0");

  s = [NSString stringWithString: s];
  h = [s hash];
  PASS(h != 0, "[NSString hash] does not return 0");
  END_SET("zero hash")
  return 0;
}