diff --git a/configs/base.yaml b/configs/base.yaml index b4d0b59..6750045 100644 --- a/configs/base.yaml +++ b/configs/base.yaml @@ -6,7 +6,6 @@ variables: ar: ar nasm: nasm objcopy: objcopy - cog: cog ccflags: [ "-I${source_root}/src/include", @@ -38,8 +37,3 @@ variables: cflags: [ "-std=c11" ] cxxflags: [ "-std=c++17" ] - - cogflags: [ - "-I", "${source_root}/scripts", - "-D", "definitions_path=${source_root}/definitions" ] - diff --git a/configs/kernel-debug.yaml b/configs/kernel-debug.yaml index b8579a3..9360c5c 100644 --- a/configs/kernel-debug.yaml +++ b/configs/kernel-debug.yaml @@ -30,8 +30,8 @@ variables: "-DPRINTF_ALIAS_STANDARD_FUNCTION_NAMES=1", "-DPRINTF_INCLUDE_CONFIG_H=1", + "-isystem${build_root}/include/libc", "-isystem${source_root}/sysroot/include", - "-isystem${source_root}/src/libraries/libc/include", "--sysroot='${source_root}/sysroot'" ] diff --git a/configs/rules.ninja b/configs/rules.ninja index 905ba97..2074166 100644 --- a/configs/rules.ninja +++ b/configs/rules.ninja @@ -1,6 +1,6 @@ # This file is automatically generated by bonnibel -rule compile_c +rule compile.c command = $cc -MMD -MF $out.d $cflags $ccflags -o $out -c $in description = Compiling $name depfile = $out.d @@ -15,7 +15,7 @@ rule dump_c_run $out; chmod a+x $out description = Dumping C arguments for $target -rule compile_cxx +rule compile.cpp command = $cxx -MMD -MF $out.d $cxxflags $ccflags -o $out -c $in description = Compiling $name depfile = $out.d @@ -30,14 +30,14 @@ rule dump_cpp_run >> $out; chmod a+x $out description = Dumping C++ arguments for $target -rule compile_asm +rule compile.s command = $nasm -o $out -felf64 -MD $out.d $asflags $in description = Assembling $name depfile = $out.d deps = gcc -rule parse_cog - command = $cog -o $out -d -D target=$target $cogflags $in +rule parse.cog + command = cog -o $out -d -D target=$target $cogflags $in description = Parsing $name rule exe diff --git a/configs/user-debug.yaml b/configs/user-debug.yaml index 1f7203a..d9b56bd 100644 --- a/configs/user-debug.yaml +++ b/configs/user-debug.yaml @@ -16,7 +16,7 @@ variables: "-U__linux__", "-isystem${source_root}/sysroot/include", - "-isystem${source_root}/src/libraries/libc/include", + "-isystem${build_root}/include/libc", "--sysroot='${source_root}/sysroot'" ] diff --git a/scripts/bonnibel/__init__.py b/scripts/bonnibel/__init__.py index 1ba3953..69d9a3e 100644 --- a/scripts/bonnibel/__init__.py +++ b/scripts/bonnibel/__init__.py @@ -1,3 +1,5 @@ +from os.path import join + class BonnibelError(Exception): def __init__(self, message): self.message = message @@ -6,3 +8,18 @@ def load_config(filename): from yaml import safe_load with open(filename, 'r') as infile: return safe_load(infile.read()) + +def mod_rel(path): + return join("${module_dir}", path) + +def target_rel(path, module=None): + if module: + return join("${target_dir}", module + ".dir", path) + else: + return join("${target_dir}", path) + +def include_rel(path, module=None): + if module: + return join("${build_root}", "include", module, path) + else: + return join("${build_root}", "include", path) diff --git a/scripts/bonnibel/action.py b/scripts/bonnibel/action.py deleted file mode 100644 index 0e3b1b9..0000000 --- a/scripts/bonnibel/action.py +++ /dev/null @@ -1,18 +0,0 @@ -class Action: - _action_map = { - '.c': Action_c, - '.C': Action_cxx, - '.cc': Action_cxx, - '.cpp': Action_cxx, - '.cxx': Action_cxx, - '.c++': Action_cxx, - '.s': Action_asm, - '.S': Action_asm, - '.cog': Action_cog, - } - - @classmethod - def find(cls, ext): - return cls._action_map.get(ext) - -class Action_c: diff --git a/scripts/bonnibel/module.py b/scripts/bonnibel/module.py index 796e13e..7f6de80 100644 --- a/scripts/bonnibel/module.py +++ b/scripts/bonnibel/module.py @@ -1,9 +1,18 @@ +from . import include_rel, mod_rel, target_rel + def resolve(path): if path.startswith('/') or path.startswith('$'): return path from pathlib import Path return str(Path(path).resolve()) +class BuildOptions: + def __init__(self, includes=tuple(), libs=tuple(), order_only=tuple()): + self.includes = list(includes) + self.libs = list(libs) + self.order_only = list(order_only) + + class Module: __fields = { # name: (type, default) @@ -11,16 +20,18 @@ class Module: "output": (str, None), "targets": (set, ()), "deps": (set, ()), + "public_headers": (set, ()), "includes": (tuple, ()), "sources": (tuple, ()), "variables": (dict, ()), "default": (bool, False), "location": (str, "jsix"), "description": (str, None), + "no_libc": (bool, False), } def __init__(self, name, modfile, root, **kwargs): - from .source import Source + from .source import make_source # Required fields self.root = root @@ -40,7 +51,8 @@ class Module: raise AttributeError(f"No attribute named {name} on Module") # Turn strings into real Source objects - self.sources = [Source(root, f) for f in self.sources] + self.sources = [make_source(root, f) for f in self.sources] + self.public_headers = [make_source(root, f) for f in self.public_headers] # Filled by Module.update self.depmods = set() @@ -66,13 +78,17 @@ class Module: def update(cls, mods): from . import BonnibelError - for mod in mods.values(): - for dep in mod.deps: + def resolve(modlist): + resolved = set() + for dep in modlist: if not dep in mods: raise BonnibelError(f"module '{mod.name}' references unknown module '{dep}'") + mod = mods[dep] + resolved.add(mod) + return resolved - depmod = mods[dep] - mod.depmods.add(depmod) + for mod in mods.values(): + mod.depmods = resolve(mod.deps) target_mods = [mod for mod in mods.values() if mod.targets] for mod in target_mods: @@ -85,112 +101,150 @@ class Module: children |= {m for m in child.depmods if not m in closed} def generate(self, output): - filename = str(output / f"module.{self.name}.ninja") + from pathlib import Path + from collections import defaultdict + from ninja.ninja_syntax import Writer + def walk_deps(deps): + open_set = set(deps) + closed_set = set() + while open_set: + dep = open_set.pop() + closed_set.add(dep) + open_set |= {m for m in dep.depmods if not m in closed_set} + return closed_set + + all_deps = walk_deps(self.depmods) + + def gather_phony(build, deps, child_rel, add_headers=False): + phony = ".headers.phony" + child_phony = [child_rel(phony, module=c.name) + for c in all_deps] + + header_targets = [] + if add_headers: + if not self.no_libc: + header_targets.append(f"${{build_root}}/include/libc/{phony}") + if self.public_headers: + header_targets.append(f"${{build_root}}/include/{self.name}/{phony}") + + build.build( + rule = "touch", + outputs = [mod_rel(phony)], + implicit = child_phony + header_targets, + order_only = list(map(mod_rel, deps)), + ) + + filename = str(output / f"headers.{self.name}.ninja") with open(filename, "w") as buildfile: - from pathlib import Path - from ninja.ninja_syntax import Writer - build = Writer(buildfile) build.comment("This file is automatically generated by bonnibel") build.newline() - build.variable("module_dir", f"${{target_dir}}/{self.name}.dir") + build.variable("module_dir", f"${{build_root}}/include/{self.name}") + + header_deps = [] + + inputs = [] + headers = set(self.public_headers) + while headers: + source = headers.pop() + headers.update(source.next) + + if source.action: + build.newline() + build.build(rule=source.action, **source.args) + + if source.gather: + header_deps += list(source.outputs) + + if source.input: + inputs.extend(map(mod_rel, source.outputs)) + + build.newline() + gather_phony(build, header_deps, include_rel) + + filename = str(output / f"module.{self.name}.ninja") + with open(filename, "w") as buildfile: + build = Writer(buildfile) + + build.comment("This file is automatically generated by bonnibel") + build.newline() + + build.variable("module_dir", target_rel(self.name + ".dir")) + + modopts = BuildOptions( + includes = [self.root, "${module_dir}"], + ) + if self.public_headers: + modopts.includes += [f"${{build_root}}/include/{self.name}"] for key, value in self.variables.items(): build.variable(key, value) build.newline() - includes = [self.root, "${module_dir}"] for include in self.includes: p = Path(include) if p.is_absolute(): - if not p in includes: - includes.append(str(p.resolve())) + if not p in modopts.includes: + modopts.includes.append(str(p.resolve())) elif include != ".": - includes.append(str(self.root / p)) - includes.append(f"${{module_dir}}/{p}") + incpath = self.root / p + destpath = mod_rel(p) + for header in incpath.rglob("*.h"): + dest_header = f"{destpath}/" + str(header.relative_to(incpath)) + modopts.includes.append(str(incpath)) + modopts.includes.append(destpath) - libs = [] - child_deps = [] - order_only = [] - closed = set() - children = set(self.depmods) - while children: - child = children.pop() - closed.add(child) + all_deps = walk_deps(self.depmods) + for dep in all_deps: + if dep.public_headers: + modopts.includes += [f"${{build_root}}/include/{dep.name}"] - includes += [f"${{target_dir}}/{child.name}.dir/{i}" for i in child.includes] - includes += [f"{child.root}/{i}" for i in child.includes] - - child_deps.append(f"${{target_dir}}/{child.name}.dir/.parse_dep.phony") - - if child.kind == "lib": - libs.append(f"${{target_dir}}/{child.output}") + if dep.kind == "lib": + modopts.libs.append(target_rel(dep.output)) else: - order_only.append(f"${{target_dir}}/{child.output}") - children |= {m for m in child.depmods if not m in closed} + modopts.order_only.append(target_rel(dep.output)) - if includes: - build.variable("ccflags", ["${ccflags}"] + [f"-I{i}" for i in includes]) - build.variable("asflags", ["${asflags}"] + [f"-I{i}" for i in includes]) + if modopts.includes: + build.variable("ccflags", ["${ccflags}"] + [f"-I{i}" for i in modopts.includes]) + build.variable("asflags", ["${asflags}"] + [f"-I{i}" for i in modopts.includes]) - if libs: - build.variable("libs", ["${libs}"] + libs) + if modopts.libs: + build.variable("libs", ["${libs}"] + modopts.libs) + + header_deps = [] inputs = [] - parse_deps = [] - parse_depfile = "${module_dir}/.parse_dep.phony" + sources = set(self.sources) + while sources: + source = sources.pop() + sources.update(source.next) - for start in self.sources: - source = start + if source.action: + build.newline() + build.build(rule=source.action, **source.args) - while source and source.action: - output = source.output + if source.gather: + header_deps += list(source.outputs) - if source.action.parse_deps: - oodeps = [parse_depfile] - else: - oodeps = [] - - if source.action.rule: - build.newline() - build.build( - rule = source.action.rule, - outputs = output.input, - inputs = source.input, - implicit = list(map(resolve, source.deps)) + - list(source.action.deps), - order_only = oodeps, - variables = {"name": source.name}, - ) - - elif source.action.implicit: - parse_deps.append(source.input) - - else: - inputs.append(source.input) - - source = output + if source.input: + inputs.extend(map(mod_rel, source.outputs)) build.newline() - build.build( - rule = "touch", - outputs = [parse_depfile], - implicit = child_deps, - order_only = parse_deps, - ) - output = f"${{target_dir}}/{self.output}" - dump = f"${{target_dir}}/{self.output}.dump" + gather_phony(build, header_deps, target_rel, add_headers=True) + + output = target_rel(self.output) + dump = output + ".dump" build.newline() build.build( rule = self.kind, outputs = output, inputs = inputs, - implicit = libs, - order_only = order_only, + implicit = modopts.libs, + order_only = modopts.order_only, ) build.newline() @@ -210,9 +264,13 @@ class Module: from .source import Source s = Source(self.root, path, **kwargs) self.sources.append(s) - return str(s.output) + return s.outputs def add_depends(self, paths, deps): for source in self.sources: - if source.name in paths: + if source.path in paths: + source.add_deps(deps) + + for source in self.public_headers: + if source.path in paths: source.add_deps(deps) diff --git a/scripts/bonnibel/project.py b/scripts/bonnibel/project.py index e71e85a..20bc6e6 100644 --- a/scripts/bonnibel/project.py +++ b/scripts/bonnibel/project.py @@ -15,7 +15,6 @@ class Project: import bonnibel from os.path import join from ninja.ninja_syntax import Writer - from . import load_config from .target import Target targets = set() @@ -40,10 +39,31 @@ class Project: build.variable("version_sha", self.version.sha) build.newline() + build.variable("cogflags", [ + "-I", "${source_root}/scripts", + "-D", "definitions_path=${source_root}/definitions", + ]) + build.newline() + for target in targets: build.subninja(output / target.name / "target.ninja") build.newline() + for mod in modules.values(): + build.subninja(output / f"headers.{mod.name}.ninja") + build.newline() + + build.build( + rule = "touch", + outputs = "${build_root}/.all_headers", + implicit = [f"${{build_root}}/include/{m.name}/.headers.phony" + for m in modules.values() if m.public_headers], + ) + build.build( + rule = "phony", + outputs = ["all-headers"], + inputs = ["${build_root}/.all_headers"]) + debugroot = output / ".debug" debugroot.mkdir(exist_ok=True) @@ -82,7 +102,6 @@ class Project: }) add_fatroot(intermediary, entry) - return mod.location from .manifest import Manifest manifest = Manifest(manifest_file, modules) diff --git a/scripts/bonnibel/source.py b/scripts/bonnibel/source.py index 020063a..aa09673 100644 --- a/scripts/bonnibel/source.py +++ b/scripts/bonnibel/source.py @@ -1,87 +1,119 @@ -class Action: - name = property(lambda self: self.__name) - implicit = property(lambda self: False) - rule = property(lambda self: None) - deps = property(lambda self: tuple()) - parse_deps = property(lambda self: False) +from os.path import join, splitext +from . import mod_rel - def __init__(self, name): - self.__name = name - - def output_of(self, path): - return None - - -class Compile(Action): - rule = property(lambda self: f'compile_{self.name}') - deps = property(lambda self: ("${module_dir}/.parse_dep.phony",)) - parse_deps = property(lambda self: True) - - def __init__(self, name, suffix = ".o"): - super().__init__(name) - self.__suffix = suffix - - def output_of(self, path): - return str(path) + self.__suffix - - -class Parse(Action): - rule = property(lambda self: f'parse_{self.name}') - - def output_of(self, path): - suffix = "." + self.name - if path.suffix == suffix: - return path.with_suffix('') +def _resolve(path): + if path.startswith('/') or path.startswith('$'): return path + from pathlib import Path + return str(Path(path).resolve()) - -class Link(Action): pass - - -class Header(Action): - implicit = property(lambda self: True) +def _dynamic_action(name): + def prop(self): + root, suffix = splitext(self.path) + return f"{name}{suffix}" + return prop class Source: - Actions = { - '.c': Compile('c'), - '.cpp': Compile('cxx'), - '.s': Compile('asm'), - '.cog': Parse('cog'), - '.o': Link('o'), - '.h': Header('h'), - '.inc': Header('inc'), - } + next = tuple() + action = None + args = dict() + gather = False + outputs = tuple() + input = False - def __init__(self, root, path, output=None, deps=tuple()): - from pathlib import Path - self.__root = Path(root) - self.__path = Path(path) - self.__output = output - self.__deps = tuple(deps) - - def __str__(self): - return self.input + def __init__(self, path, root = "${module_dir}", deps=tuple()): + self.path = path + self.root = root + self.deps = deps def add_deps(self, deps): - self.__deps += tuple(deps) + self.deps += tuple(deps) @property - def action(self): - suffix = self.__path.suffix - return self.Actions.get(suffix) + def fullpath(self): + return join(self.root, self.path) + +class ParseSource(Source): + action = property(_dynamic_action("parse")) @property def output(self): - if not self.action: - return None + root, _ = splitext(self.path) + return root - path = self.__output - if path is None: - path = self.action.output_of(self.__path) + @property + def outputs(self): + return (self.output,) - return path and Source("${module_dir}", path) + @property + def gather(self): + _, suffix = splitext(self.output) + return suffix in (".h", ".inc") - deps = property(lambda self: self.__deps) - name = property(lambda self: str(self.__path)) - input = property(lambda self: str(self.__root / self.__path)) + @property + def next(self): + _, suffix = splitext(self.output) + nextType = { + ".s": CompileSource, + ".cpp": CompileSource, + }.get(suffix) + + if nextType: + return (nextType(self.output),) + return tuple() + + @property + def args(self): + return dict( + outputs = list(map(mod_rel, self.outputs)), + inputs = [self.fullpath], + implicit = list(map(_resolve, self.deps)), + variables = dict(name=self.path), + ) + +class HeaderSource(Source): + action = "cp" + gather = True + + @property + def outputs(self): + return (self.path,) + + @property + def args(self): + return dict( + outputs = [mod_rel(self.path)], + inputs = [join(self.root, self.path)], + implicit = list(map(_resolve, self.deps)), + variables = dict(name=self.path), + ) + +class CompileSource(Source): + action = property(_dynamic_action("compile")) + input = True + + @property + def outputs(self): + return (self.path + ".o",) + + @property + def args(self): + return dict( + outputs = list(map(mod_rel, self.outputs)), + inputs = [join(self.root, self.path)], + implicit = list(map(_resolve, self.deps)) + [mod_rel(".headers.phony")], + variables = dict(name=self.path), + ) + +def make_source(root, path): + _, suffix = splitext(path) + + if suffix in (".s", ".c", ".cpp"): + return CompileSource(path, root) + elif suffix in (".cog",): + return ParseSource(path, root) + elif suffix in (".h", ".inc"): + return HeaderSource(path, root) + else: + raise RuntimeError(f"{path} has no Source type") diff --git a/src/kernel/kernel.module b/src/kernel/kernel.module index 1e95fd3..d02f113 100644 --- a/src/kernel/kernel.module +++ b/src/kernel/kernel.module @@ -7,7 +7,6 @@ kernel = module("kernel", targets = [ "kernel" ], description = "jsix kernel", deps = [ "util", "cpu", "bootproto", "j6" ], - includes = [ "." ], sources = [ "apic.cpp", "assert.cpp", diff --git a/src/kernel/panic.serial/serial.module b/src/kernel/panic.serial/serial.module index 665ca5a..cfe6d91 100644 --- a/src/kernel/panic.serial/serial.module +++ b/src/kernel/panic.serial/serial.module @@ -4,6 +4,7 @@ panic = module("panic.serial", kind = "exe", targets = [ "kernel" ], deps = [ "util", "elf", "kernel" ], + includes = [ ".." ], description = "Serial panic handler", sources = [ "display.cpp", diff --git a/src/libraries/bootproto/bootproto.module b/src/libraries/bootproto/bootproto.module index 7496939..6914858 100644 --- a/src/libraries/bootproto/bootproto.module +++ b/src/libraries/bootproto/bootproto.module @@ -2,11 +2,14 @@ bp = module("bootproto", kind = "lib", - includes = [ "include" ], - sources = [ + public_headers = [ + "bootproto/bootconfig.h", + "bootproto/init.h", + "bootproto/kernel.h", + "bootproto/memory.h.cog", ]) from os.path import join layout = join(source_root, "definitions/memory_layout.yaml") -bp.add_input("include/bootproto/memory.h.cog", deps=[layout]) +bp.add_depends("bootproto/memory.h.cog", deps=[layout]) diff --git a/src/libraries/bootproto/include/bootproto/bootconfig.h b/src/libraries/bootproto/bootproto/bootconfig.h similarity index 100% rename from src/libraries/bootproto/include/bootproto/bootconfig.h rename to src/libraries/bootproto/bootproto/bootconfig.h diff --git a/src/libraries/bootproto/include/bootproto/init.h b/src/libraries/bootproto/bootproto/init.h similarity index 100% rename from src/libraries/bootproto/include/bootproto/init.h rename to src/libraries/bootproto/bootproto/init.h diff --git a/src/libraries/bootproto/include/bootproto/kernel.h b/src/libraries/bootproto/bootproto/kernel.h similarity index 100% rename from src/libraries/bootproto/include/bootproto/kernel.h rename to src/libraries/bootproto/bootproto/kernel.h diff --git a/src/libraries/bootproto/include/bootproto/memory.h.cog b/src/libraries/bootproto/bootproto/memory.h.cog similarity index 100% rename from src/libraries/bootproto/include/bootproto/memory.h.cog rename to src/libraries/bootproto/bootproto/memory.h.cog diff --git a/src/libraries/cpu/cpu.module b/src/libraries/cpu/cpu.module index 27e965a..ffaed44 100644 --- a/src/libraries/cpu/cpu.module +++ b/src/libraries/cpu/cpu.module @@ -2,7 +2,10 @@ module("cpu", kind = "lib", - includes = ["include"], sources = [ "cpu_id.cpp", + ], + public_headers = [ + "cpu/cpu_id.h", + "cpu/features.inc", ]) diff --git a/src/libraries/cpu/include/cpu/cpu_id.h b/src/libraries/cpu/cpu/cpu_id.h similarity index 100% rename from src/libraries/cpu/include/cpu/cpu_id.h rename to src/libraries/cpu/cpu/cpu_id.h diff --git a/src/libraries/cpu/include/cpu/features.inc b/src/libraries/cpu/cpu/features.inc similarity index 100% rename from src/libraries/cpu/include/cpu/features.inc rename to src/libraries/cpu/cpu/features.inc diff --git a/src/libraries/elf/elf.module b/src/libraries/elf/elf.module index 77ce5c3..ec15d95 100644 --- a/src/libraries/elf/elf.module +++ b/src/libraries/elf/elf.module @@ -2,8 +2,11 @@ module("elf", kind = "lib", - includes = [ "include" ], deps = [ "util" ], sources = [ "file.cpp", + ], + public_headers = [ + "elf/file.h", + "elf/headers.h", ]) diff --git a/src/libraries/elf/include/elf/file.h b/src/libraries/elf/elf/file.h similarity index 100% rename from src/libraries/elf/include/elf/file.h rename to src/libraries/elf/elf/file.h diff --git a/src/libraries/elf/include/elf/headers.h b/src/libraries/elf/elf/headers.h similarity index 100% rename from src/libraries/elf/include/elf/headers.h rename to src/libraries/elf/elf/headers.h diff --git a/src/libraries/j6/j6.module b/src/libraries/j6/j6.module index c15db8e..78e5c88 100644 --- a/src/libraries/j6/j6.module +++ b/src/libraries/j6/j6.module @@ -2,14 +2,25 @@ j6 = module("j6", kind = "lib", - includes = [ "include" ], sources = [ "init.cpp", - "include/j6/caps.h.cog", - "include/j6/syscalls.h.cog", - "include/j6/sysconf.h.cog", "syscalls.s.cog", "sysconf.cpp.cog", + ], + public_headers = [ + "j6/caps.h.cog", + "j6/errors.h", + "j6/flags.h", + "j6/init.h", + "j6/signals.h", + "j6/syscalls.h.cog", + "j6/sysconf.h.cog", + "j6/types.h", + + "j6/tables/log_areas.inc", + "j6/tables/object_types.inc", + "j6/tables/syscalls.inc", + "j6/tables/vm_flags.inc", ]) from glob import glob @@ -19,13 +30,13 @@ sysconf = join(source_root, "definitions/sysconf.yaml") definitions = glob('definitions/**/*.def', recursive=True) j6.add_depends([ - "include/j6/caps.h.cog", - "include/j6/syscalls.h.cog", + "j6/caps.h.cog", + "j6/syscalls.h.cog", "syscalls.s.cog", ], definitions) j6.add_depends([ - "include/j6/sysconf.h.cog", + "j6/sysconf.h.cog", "sysconf.cpp.cog", ], [sysconf]) diff --git a/src/libraries/j6/include/j6/caps.h.cog b/src/libraries/j6/j6/caps.h.cog similarity index 100% rename from src/libraries/j6/include/j6/caps.h.cog rename to src/libraries/j6/j6/caps.h.cog diff --git a/src/libraries/j6/include/j6/errors.h b/src/libraries/j6/j6/errors.h similarity index 100% rename from src/libraries/j6/include/j6/errors.h rename to src/libraries/j6/j6/errors.h diff --git a/src/libraries/j6/include/j6/flags.h b/src/libraries/j6/j6/flags.h similarity index 100% rename from src/libraries/j6/include/j6/flags.h rename to src/libraries/j6/j6/flags.h diff --git a/src/libraries/j6/include/j6/init.h b/src/libraries/j6/j6/init.h similarity index 100% rename from src/libraries/j6/include/j6/init.h rename to src/libraries/j6/j6/init.h diff --git a/src/libraries/j6/include/j6/signals.h b/src/libraries/j6/j6/signals.h similarity index 100% rename from src/libraries/j6/include/j6/signals.h rename to src/libraries/j6/j6/signals.h diff --git a/src/libraries/j6/include/j6/syscalls.h.cog b/src/libraries/j6/j6/syscalls.h.cog similarity index 100% rename from src/libraries/j6/include/j6/syscalls.h.cog rename to src/libraries/j6/j6/syscalls.h.cog diff --git a/src/libraries/j6/include/j6/sysconf.h.cog b/src/libraries/j6/j6/sysconf.h.cog similarity index 100% rename from src/libraries/j6/include/j6/sysconf.h.cog rename to src/libraries/j6/j6/sysconf.h.cog diff --git a/src/libraries/j6/include/j6/tables/log_areas.inc b/src/libraries/j6/j6/tables/log_areas.inc similarity index 100% rename from src/libraries/j6/include/j6/tables/log_areas.inc rename to src/libraries/j6/j6/tables/log_areas.inc diff --git a/src/libraries/j6/include/j6/tables/object_types.inc b/src/libraries/j6/j6/tables/object_types.inc similarity index 100% rename from src/libraries/j6/include/j6/tables/object_types.inc rename to src/libraries/j6/j6/tables/object_types.inc diff --git a/src/libraries/j6/include/j6/tables/syscalls.inc b/src/libraries/j6/j6/tables/syscalls.inc similarity index 100% rename from src/libraries/j6/include/j6/tables/syscalls.inc rename to src/libraries/j6/j6/tables/syscalls.inc diff --git a/src/libraries/j6/include/j6/tables/vm_flags.inc b/src/libraries/j6/j6/tables/vm_flags.inc similarity index 100% rename from src/libraries/j6/include/j6/tables/vm_flags.inc rename to src/libraries/j6/j6/tables/vm_flags.inc diff --git a/src/libraries/j6/include/j6/types.h b/src/libraries/j6/j6/types.h similarity index 100% rename from src/libraries/j6/include/j6/types.h rename to src/libraries/j6/j6/types.h diff --git a/src/libraries/libc/include/assert.h b/src/libraries/libc/assert.h similarity index 100% rename from src/libraries/libc/include/assert.h rename to src/libraries/libc/assert.h diff --git a/src/libraries/libc/include/ctype.h b/src/libraries/libc/ctype.h similarity index 100% rename from src/libraries/libc/include/ctype.h rename to src/libraries/libc/ctype.h diff --git a/src/libraries/libc/include/errno.h b/src/libraries/libc/errno.h similarity index 100% rename from src/libraries/libc/include/errno.h rename to src/libraries/libc/errno.h diff --git a/src/libraries/libc/include/float.h b/src/libraries/libc/float.h similarity index 100% rename from src/libraries/libc/include/float.h rename to src/libraries/libc/float.h diff --git a/src/libraries/libc/include/inttypes.h b/src/libraries/libc/inttypes.h similarity index 100% rename from src/libraries/libc/include/inttypes.h rename to src/libraries/libc/inttypes.h diff --git a/src/libraries/libc/include/iso646.h b/src/libraries/libc/iso646.h similarity index 100% rename from src/libraries/libc/include/iso646.h rename to src/libraries/libc/iso646.h diff --git a/src/libraries/libc/include/j6libc/aux.h b/src/libraries/libc/j6libc/aux.h similarity index 100% rename from src/libraries/libc/include/j6libc/aux.h rename to src/libraries/libc/j6libc/aux.h diff --git a/src/libraries/libc/include/j6libc/config.h b/src/libraries/libc/j6libc/config.h similarity index 100% rename from src/libraries/libc/include/j6libc/config.h rename to src/libraries/libc/j6libc/config.h diff --git a/src/libraries/libc/include/j6libc/cpp.h b/src/libraries/libc/j6libc/cpp.h similarity index 100% rename from src/libraries/libc/include/j6libc/cpp.h rename to src/libraries/libc/j6libc/cpp.h diff --git a/src/libraries/libc/include/j6libc/glue.h b/src/libraries/libc/j6libc/glue.h similarity index 100% rename from src/libraries/libc/include/j6libc/glue.h rename to src/libraries/libc/j6libc/glue.h diff --git a/src/libraries/libc/include/j6libc/int.h b/src/libraries/libc/j6libc/int.h similarity index 100% rename from src/libraries/libc/include/j6libc/int.h rename to src/libraries/libc/j6libc/int.h diff --git a/src/libraries/libc/include/j6libc/int_widths.h b/src/libraries/libc/j6libc/int_widths.h similarity index 100% rename from src/libraries/libc/include/j6libc/int_widths.h rename to src/libraries/libc/j6libc/int_widths.h diff --git a/src/libraries/libc/include/j6libc/max_align_t.h b/src/libraries/libc/j6libc/max_align_t.h similarity index 100% rename from src/libraries/libc/include/j6libc/max_align_t.h rename to src/libraries/libc/j6libc/max_align_t.h diff --git a/src/libraries/libc/include/j6libc/null.h b/src/libraries/libc/j6libc/null.h similarity index 100% rename from src/libraries/libc/include/j6libc/null.h rename to src/libraries/libc/j6libc/null.h diff --git a/src/libraries/libc/include/j6libc/sig_atomic_t.h b/src/libraries/libc/j6libc/sig_atomic_t.h similarity index 100% rename from src/libraries/libc/include/j6libc/sig_atomic_t.h rename to src/libraries/libc/j6libc/sig_atomic_t.h diff --git a/src/libraries/libc/include/j6libc/size_t.h b/src/libraries/libc/j6libc/size_t.h similarity index 100% rename from src/libraries/libc/include/j6libc/size_t.h rename to src/libraries/libc/j6libc/size_t.h diff --git a/src/libraries/libc/include/j6libc/wchar_t.h b/src/libraries/libc/j6libc/wchar_t.h similarity index 100% rename from src/libraries/libc/include/j6libc/wchar_t.h rename to src/libraries/libc/j6libc/wchar_t.h diff --git a/src/libraries/libc/include/j6libc/wctype_t.h b/src/libraries/libc/j6libc/wctype_t.h similarity index 100% rename from src/libraries/libc/include/j6libc/wctype_t.h rename to src/libraries/libc/j6libc/wctype_t.h diff --git a/src/libraries/libc/include/j6libc/wint_t.h b/src/libraries/libc/j6libc/wint_t.h similarity index 100% rename from src/libraries/libc/include/j6libc/wint_t.h rename to src/libraries/libc/j6libc/wint_t.h diff --git a/src/libraries/libc/libc.module b/src/libraries/libc/libc.module index 815ac2e..cda9d00 100644 --- a/src/libraries/libc/libc.module +++ b/src/libraries/libc/libc.module @@ -1,166 +1,33 @@ # vim: ft=python +# Normally I prefer listing every source file so that ninja can pick +# up on added files and regenerate appropriately, but libc has _so_ +# many files that it's unweildy. So if a file is added or removed in +# libc, remember to run configure again. + +def glob(ext): + from glob import glob + + def resolve(path): + from pathlib import Path + return str(Path(path).relative_to(module_root)) + + return list(map(resolve, glob(f"{module_root}/**/*.{ext}", recursive=True))) + +sources = [] +for ext in ("c", "cpp", "s"): + sources += glob(ext) + glob(ext + ".cog") + +headers = [] +for ext in ("h", "inc"): + headers += glob(ext) + glob(ext + ".cog") + libc = module("libc", kind = "lib", - includes = [ "include" ], deps = [ "j6" ], - sources = [ - "arch/x86_64/_Exit.s", - "arch/x86_64/crt0.s", - "ctype/isalnum.c", - "ctype/isalpha.c", - "ctype/isblank.c", - "ctype/iscntrl.c", - "ctype/isdigit.c", - "ctype/isgraph.c", - "ctype/islower.c", - "ctype/isprint.c", - "ctype/ispunct.c", - "ctype/isspace.c", - "ctype/isupper.c", - "ctype/isxdigit.c", - "ctype/tolower.c", - "ctype/toupper.c", - "inttypes/imaxabs.c", - "inttypes/imaxdiv.c", - "inttypes/strtoimax.c", - "inttypes/strtoumax.c", - "locale/localeconv.c", - "locale/setlocale.c", - "j6libc/assert.c", - "j6libc/errno.c", - "j6libc/allocpages.c", - "j6libc/atomax.c", - "j6libc/closeall.c", - "j6libc/close.c", - "j6libc/digits.c", - "j6libc/filemode.c", - "j6libc/fillbuffer.c", - "j6libc/flushbuffer.c", - "j6libc/is_leap.c", - "j6libc/load_lc_collate.c", - "j6libc/load_lc_ctype.c", - "j6libc/load_lc_messages.c", - "j6libc/load_lc_monetary.c", - "j6libc/load_lc_numeric.c", - "j6libc/load_lc_time.c", - "j6libc/load_lines.c", - "j6libc/open.c", - "j6libc/prepread.c", - "j6libc/prepwrite.c", - "j6libc/print.c", - "j6libc/rename.c", - "j6libc/scan.c", - "j6libc/seed.c", - "j6libc/seek.c", - "j6libc/stdinit.c", - "j6libc/strtox_main.c", - "j6libc/strtox_prelim.c", - "j6libc/sbrk.c", - "signal/raise.c", - "signal/signal.c", - "stdio/clearerr.c", - "stdio/fclose.c", - "stdio/feof.c", - "stdio/ferror.c", - "stdio/fflush.c", - "stdio/fgetc.c", - "stdio/fgetpos.c", - "stdio/fgets.c", - "stdio/fopen.c", - "stdio/fprintf.c", - "stdio/fputc.c", - "stdio/fputs.c", - "stdio/fread.c", - "stdio/freopen.c", - "stdio/fscanf.c", - "stdio/fseek.c", - "stdio/fsetpos.c", - "stdio/ftell.c", - "stdio/fwrite.c", - "stdio/getc.c", - "stdio/getchar.c", - "stdio/perror.c", - "stdio/printf.c", - "stdio/putc.c", - "stdio/putchar.c", - "stdio/puts.c", - "stdio/remove.c", - "stdio/rename.c", - "stdio/rewind.c", - "stdio/scanf.c", - "stdio/setbuf.c", - "stdio/setvbuf.c", - "stdio/snprintf.c", - "stdio/sprintf.c", - "stdio/sscanf.c", - "stdio/tmpfile.c", - "stdio/tmpnam.c", - "stdio/ungetc.c", - "stdio/vfprintf.c", - "stdio/vfscanf.c", - "stdio/vprintf.c", - "stdio/vscanf.c", - "stdio/vsnprintf.c", - "stdio/vsprintf.c", - "stdio/vsscanf.c", - "stdlib/abort.c", - "stdlib/abs.c", - "stdlib/atexit.c", - "stdlib/atoi.c", - "stdlib/atol.c", - "stdlib/atoll.c", - "stdlib/bsearch.c", - "stdlib/div.c", - "stdlib/exit.c", - "stdlib/_Exit.c", - "stdlib/getenv.c", - "stdlib/labs.c", - "stdlib/ldiv.c", - "stdlib/llabs.c", - "stdlib/lldiv.c", - "stdlib/malloc.c", - "stdlib/qsort.c", - "stdlib/rand.c", - "stdlib/srand.c", - "stdlib/strtol.c", - "stdlib/strtoll.c", - "stdlib/strtoul.c", - "stdlib/strtoull.c", - "stdlib/system.c", - "string/memchr.c", - "string/memcmp.c", - "string/memcpy.c", - "string/memmove.c", - "string/memset.c", - "string/strcat.c", - "string/strchr.c", - "string/strcmp.c", - "string/strcoll.c", - "string/strcpy.c", - "string/strcspn.c", - "string/strerror.c", - "string/strlen.c", - "string/strncat.c", - "string/strncmp.c", - "string/strncpy.c", - "string/strpbrk.c", - "string/strrchr.c", - "string/strspn.c", - "string/strstr.c", - "string/strtok.c", - "string/strxfrm.c", - "time/asctime.c", - "time/clock.c", - "time/ctime.c", - "time/difftime.c", - "time/gmtime.c", - "time/localtime.c", - "time/mktime.c", - "time/strftime.c", - "time/time.c", - "time/timespec_get.c", - ]) + sources = sources, + public_headers = headers, + ) libc.variables["ccflags"] = [ "${ccflags}", diff --git a/src/libraries/libc/include/limits.h b/src/libraries/libc/limits.h similarity index 100% rename from src/libraries/libc/include/limits.h rename to src/libraries/libc/limits.h diff --git a/src/libraries/libc/include/locale.h b/src/libraries/libc/locale.h similarity index 100% rename from src/libraries/libc/include/locale.h rename to src/libraries/libc/locale.h diff --git a/src/libraries/libc/include/signal.h b/src/libraries/libc/signal.h similarity index 100% rename from src/libraries/libc/include/signal.h rename to src/libraries/libc/signal.h diff --git a/src/libraries/libc/include/stdalign.h b/src/libraries/libc/stdalign.h similarity index 100% rename from src/libraries/libc/include/stdalign.h rename to src/libraries/libc/stdalign.h diff --git a/src/libraries/libc/include/stdarg.h b/src/libraries/libc/stdarg.h similarity index 100% rename from src/libraries/libc/include/stdarg.h rename to src/libraries/libc/stdarg.h diff --git a/src/libraries/libc/include/stdbool.h b/src/libraries/libc/stdbool.h similarity index 100% rename from src/libraries/libc/include/stdbool.h rename to src/libraries/libc/stdbool.h diff --git a/src/libraries/libc/include/stddef.h b/src/libraries/libc/stddef.h similarity index 100% rename from src/libraries/libc/include/stddef.h rename to src/libraries/libc/stddef.h diff --git a/src/libraries/libc/include/stdint.h b/src/libraries/libc/stdint.h similarity index 100% rename from src/libraries/libc/include/stdint.h rename to src/libraries/libc/stdint.h diff --git a/src/libraries/libc/include/stdio.h b/src/libraries/libc/stdio.h similarity index 100% rename from src/libraries/libc/include/stdio.h rename to src/libraries/libc/stdio.h diff --git a/src/libraries/libc/include/stdlib.h b/src/libraries/libc/stdlib.h similarity index 99% rename from src/libraries/libc/include/stdlib.h rename to src/libraries/libc/stdlib.h index d32dfb4..781cde5 100644 --- a/src/libraries/libc/include/stdlib.h +++ b/src/libraries/libc/stdlib.h @@ -112,6 +112,8 @@ void free( void * ptr ); */ void * realloc( void * ptr, size_t size ); +int posix_memalign(void**, size_t, size_t); + /* Communication with the environment */ /* These two can be passed to exit() or _Exit() as status values, to signal diff --git a/src/libraries/libc/include/stdnoreturn.h b/src/libraries/libc/stdnoreturn.h similarity index 100% rename from src/libraries/libc/include/stdnoreturn.h rename to src/libraries/libc/stdnoreturn.h diff --git a/src/libraries/libc/include/string.h b/src/libraries/libc/string.h similarity index 100% rename from src/libraries/libc/include/string.h rename to src/libraries/libc/string.h diff --git a/src/libraries/libc/tests/_PDCLIB_iotest.h b/src/libraries/libc/tests/_PDCLIB_iotest.h deleted file mode 100644 index 3c04980..0000000 --- a/src/libraries/libc/tests/_PDCLIB_iotest.h +++ /dev/null @@ -1,169 +0,0 @@ -/* PDCLib testing suite <_PDCLIB_test.h> - - This file is part of the Public Domain C Library (PDCLib). - Permission is granted to use, modify, and / or redistribute at will. -*/ - -/* -------------------------------------------------------------------------- */ -/* Helper macros for printf() / scanf() tests */ -/* -------------------------------------------------------------------------- */ -/* Tucked away in a seperate header because these are ugly, complex, and not */ -/* needed in 95% of all test cases. */ -/* -------------------------------------------------------------------------- */ -/* ...scanf() tests */ -#if defined( _PDCLIB_FILEIO ) - #define PREPARE_SOURCE( input_string ) \ - rewind( source ); \ - fwrite( input_string, 1, sizeof( input_string ), source ); \ - rewind( source ); -#elif defined( _PDCLIB_STRINGIO ) - #define PREPARE_SOURCE( input_string ) \ - memcpy( source, input_string, sizeof( input_string ) ); -#endif - -/* Virtually everything in the printf() / scanf() test drivers is heavily - depending on the platform, i.e. the width of the integer values. To do - proper domain tests, we need the limits of the integers (largest and - smallest value), which we can get from . But we also need the - string representations of these numbers, to the various bases, which of - course vary depending on how the platform defines 'int' and 'long'. -*/ - -#define sym2v( x ) #x -#define sym2s( x ) sym2v( x ) - -#if __SIZEOF_INT__ == 2 - -#define UINT_DIG 5 -#define INT_DIG 5 -#define INT_DIG_LESS1 "4" -#define INT_DIG_PLUS1 "6" -#define INT_DIG_PLUS2 "7" -#define INT_HEXDIG "FFF" -#define INT_hexdig "fff" -#define INT_OCTDIG "177777" -#define INT_MAX_DEZ_STR "32767" -#define INT_MIN_DEZ_STR "32768" -#define UINT_MAX_DEZ_STR "65535" -#define INT_MAX_OCT_STR -#define INT_MIN_OCT_STR -#define UINT_MAX_OCT_STR -#define INT_MAX_HEX_STR -#define INT_MIN_HEX_STR -#define UINT_MAX_HEX_STR - -#elif __SIZEOF_INT__ == 4 - -#define UINT_DIG 10 -#define INT_DIG 10 -#define INT_DIG_LESS1 "9" -#define INT_DIG_PLUS1 "11" -#define INT_DIG_PLUS2 "12" -#define INT_HEXDIG "FFFFFFF" -#define INT_hexdig "fffffff" -#define INT_OCTDIG "37777777777" -#define INT_MAX_DEZ_STR "2147483647" -#define INT_MIN_DEZ_STR "2147483648" -#define UINT_MAX_DEZ_STR "4294967295" -#define INT_MAX_OCT_STR -#define INT_MIN_OCT_STR -#define UINT_MAX_OCT_STR -#define INT_MAX_HEX_STR -#define INT_MIN_HEX_STR -#define UINT_MAX_HEX_STR - -#elif __SIZEOF_INT__ == 8 - -#define UINT_DIG 20 -#define INT_DIG 19 -#define INT_DIG_LESS1 "18" -#define INT_DIG_PLUS1 "20" -#define INT_DIG_PLUS2 "21" -#define INT_HEXDIG "FFFFFFFFFFFFFFF" -#define INT_hexdig "fffffffffffffff" -#define INT_OCTDIG "1777777777777777777777" -#define INT_MAX_DEZ_STR "9223372036854775807" -#define INT_MIN_DEZ_STR "9223372036854775808" -#define UINT_MAX_DEZ_STR "18446744073709551615" -#define INT_MAX_OCT_STR -#define INT_MIN_OCT_STR -#define UINT_MAX_OCT_STR -#define INT_MAX_HEX_STR -#define INT_MIN_HEX_STR -#define UINT_MAX_HEX_STR - -#else - -#error Unsupported width of 'int' (neither 16, 32, nor 64 bit). - -#endif - - -#if __SIZEOF_LONG__ == 4 - -#define ULONG_DIG 10 -#define LONG_DIG 10 -#define LONG_MAX_DEZ_STR "2147483647" -#define LONG_MIN_DEZ_STR "2147483648" -#define ULONG_MAX_DEZ_STR "4294967295" -#define LONG_MAX_OCT_STR -#define LONG_MIN_OCT_STR -#define ULONG_MAX_OCT_STR -#define LONG_MAX_HEX_STR -#define LONG_MIN_HEX_STR -#define ULONG_MAX_HEX_STR - -#elif __SIZEOF_LONG__ == 8 - -#define ULONG_DIG 20 -#define LONG_DIG 19 -#define LONG_MAX_DEZ_STR "9223372036854775807" -#define LONG_MIN_DEZ_STR "9223372036854775808" -#define ULONG_MAX_DEZ_STR "18446744073709551615" -#define LONG_MAX_OCT_STR -#define LONG_MIN_OCT_STR -#define ULONG_MAX_OCT_STR -#define LONG_MAX_HEX_STR -#define LONG_MIN_HEX_STR -#define ULONG_MAX_HEX_STR - -#else - -#error Unsupported width of 'long' (neither 32 nor 64 bit). - -#endif - - -#if __SIZEOF_LONG_LONG__ == 8 - -#define ULLONG_DIG 20 -#define LLONG_DIG 19 -#define LLONG_MAX_DEZ_STR "9223372036854775807" -#define LLONG_MIN_DEZ_STR "9223372036854775808" -#define ULLONG_MAX_DEZ_STR "18446744073709551615" -#define LLONG_MAX_OCT_STR -#define LLONG_MIN_OCT_STR -#define ULLONG_MAX_OCT_STR -#define LLONG_MAX_HEX_STR -#define LLONG_MIN_HEX_STR -#define ULLONG_MAX_HEX_STR - -#elif __SIZEOF_LONG_LONG__ == 16 - -#define ULLONG_DIG 38 -#define LLONG_DIG 38 -#define LLONG_MAX_DEZ_STR "170141183460469231731687303715884105727" -#define LLONG_MIN_DEZ_STR "170141183460469231731687303715884105728" -#define ULLONG_MAX_DEZ_STR "340282366920938463463374607431768211455" -#define LLONG_MAX_OCT_STR -#define LLONG_MIN_OCT_STR -#define ULLONG_MAX_OCT_STR -#define LLONG_MAX_HEX_STR -#define LLONG_MIN_HEX_STR -#define ULLONG_MAX_HEX_STR - -#else - -#error Unsupported width of 'long long' (neither 64 nor 128 bit). - -#endif diff --git a/src/libraries/libc/tests/_PDCLIB_test.h b/src/libraries/libc/tests/_PDCLIB_test.h deleted file mode 100644 index 2ce525c..0000000 --- a/src/libraries/libc/tests/_PDCLIB_test.h +++ /dev/null @@ -1,101 +0,0 @@ -/* PDCLib testing suite <_PDCLIB_test.h> - - This file is part of the Public Domain C Library (PDCLib). - Permission is granted to use, modify, and / or redistribute at will. -*/ - -/* -------------------------------------------------------------------------- */ -/* Helper macros for test drivers */ -/* -------------------------------------------------------------------------- */ - -#define fprintf j6libc_fprintf -#define stderr j6libc_stderr -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#undef stderr -#undef fprintf - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wincompatible-library-redeclaration" -struct _IO_FILE; -extern struct _IO_FILE *stderr; -extern int fprintf(struct _IO_FILE *, const char *, ...); -#pragma clang diagnostic pop - -/* Host system sys/types.h */ -#include - -/* Some strings used for and testing. */ -static const char abcde[] = "abcde"; -static const char abcdx[] = "abcdx"; -static const char teststring[] = "1234567890\nABCDEFGHIJKLMNOPQRSTUVWXYZ\nabcdefghijklmnopqrstuvwxyz\n"; - -/* Temporary file names */ -static const char testfile[]="testing/testfile"; -static const char testfile1[]="testing/testfile1"; -static const char testfile2[]="testing/testfile2"; - -/* Host system fork(), waitpid(), and _exit() */ -pid_t fork(void); -pid_t waitpid(pid_t, int *, int); -void _exit(int); - -#define START_SUITE(name) \ - int run_suite_ ##name (void) { \ - int TEST_RESULTS = 0; - -#define END_SUITE \ - return TEST_RESULTS; \ - } - -#define DECLARE_SUITE(name) extern int run_suite_ ##name (void) -#define RUN_TEST(name) TEST_RESULTS += test__ ##name(); - -#define START_TEST(name) \ - int test__ ##name (void) { \ - int TEST_RESULTS = 0; - -#define END_TEST \ - return TEST_RESULTS; \ - } - -/* TESTCASE() - generic test */ -#define TESTCASE( x ) \ - do { \ - pid_t pid = fork(); \ - if ( !pid ) _exit((x) ? 0 : 0xFF); \ - else { \ - int __rc = 0; \ - waitpid(pid, &__rc, 0); \ - if ( __rc & 0xff00 ) { \ - TEST_RESULTS += 1; \ - fprintf( stderr, "FAILED: " __FILE__ ":%s, line %d - %s\n", __func__, __LINE__, #x ); \ - } \ - } \ - } while(0) - -/* TESTCASE_REQUIRE() - must-pass test; return early otherwise */ -#define TESTCASE_REQUIRE( x ) \ - do { \ - pid_t pid = fork(); \ - if ( !pid ) _exit((x) ? 0 : 0xFF); \ - else { \ - int __rc = 0; \ - waitpid(pid, &__rc, 0); \ - if ( __rc & 0xff00 ) { \ - TEST_RESULTS += 1; \ - fprintf( stderr, "FAILED: " __FILE__ ":%s, line %d - %s\n", __func__, __LINE__, #x ); \ - return TEST_RESULTS; \ - } \ - } \ - } while(0) diff --git a/src/libraries/libc/tests/main.c b/src/libraries/libc/tests/main.c deleted file mode 100644 index 3e0c481..0000000 --- a/src/libraries/libc/tests/main.c +++ /dev/null @@ -1,32 +0,0 @@ -#include "_PDCLIB_test.h" - -DECLARE_SUITE(internal); - -DECLARE_SUITE(assert); -DECLARE_SUITE(ctype); -DECLARE_SUITE(inttypes); -DECLARE_SUITE(locale); -DECLARE_SUITE(stdarg); -DECLARE_SUITE(stdio); -DECLARE_SUITE(stdlib); -DECLARE_SUITE(string); -DECLARE_SUITE(time); - -int main(int argc, const char **argv) -{ - int result = 0; - - result += run_suite_internal(); - - result += run_suite_assert(); - result += run_suite_ctype(); - result += run_suite_inttypes(); - result += run_suite_locale(); - result += run_suite_stdarg(); - result += run_suite_stdio(); - result += run_suite_stdlib(); - result += run_suite_string(); - result += run_suite_time(); - - return result; -} diff --git a/src/libraries/libc/tests/printf_testcases.h b/src/libraries/libc/tests/printf_testcases.h deleted file mode 100644 index 68159df..0000000 --- a/src/libraries/libc/tests/printf_testcases.h +++ /dev/null @@ -1,444 +0,0 @@ -#define PRINTF_TEST( expected_rc, expected_string, ... ) do { \ - TEST_RESULTS += DO_TESTPRINTF(IMPLFILE, __FILE__, __LINE__, expected_rc, expected_string, __VA_ARGS__); \ - } while (0); - - - { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wformat" -#if CHAR_MIN == -128 - assert(CHAR_MIN == -128); - PRINTF_TEST( 4, "-128", "%hhd", CHAR_MIN ); - assert(CHAR_MAX == 127); - PRINTF_TEST( 3, "127", "%hhd", CHAR_MAX ); -#else - assert(CHAR_MIN == 0); - PRINTF_TEST( 1, "0", "%hhu", CHAR_MIN ); - assert(CHAR_MAX == 255); - PRINTF_TEST( 3, "255", "%hhu", CHAR_MAX ); -#endif - PRINTF_TEST( 1, "0", "%hhd", 0 ); - assert(SHRT_MIN == -32768); - PRINTF_TEST( 6, "-32768", "%hd", SHRT_MIN ); - assert(SHRT_MAX == 32767); - PRINTF_TEST( 5, "32767", "%hd", SHRT_MAX ); - PRINTF_TEST( 1, "0", "%hd", 0 ); - PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%d", INT_MIN ); - PRINTF_TEST( INT_DIG, INT_MAX_DEZ_STR, "%d", INT_MAX ); - PRINTF_TEST( 1, "0", "%d", 0 ); - PRINTF_TEST( LONG_DIG + 1, "-" LONG_MIN_DEZ_STR, "%ld", LONG_MIN ); - PRINTF_TEST( LONG_DIG, LONG_MAX_DEZ_STR, "%ld", LONG_MAX ); - PRINTF_TEST( 1, "0", "%ld", 0l ); - PRINTF_TEST( LLONG_DIG + 1, "-" LLONG_MIN_DEZ_STR, "%lld", LLONG_MIN ); - PRINTF_TEST( LLONG_DIG, LLONG_MAX_DEZ_STR, "%lld", LLONG_MAX ); - PRINTF_TEST( 1, "0", "%lld", 0ll ); - PRINTF_TEST( 3, "255", "%hhu", UCHAR_MAX ); - PRINTF_TEST( 3, "255", "%hhu", (unsigned char)-1 ); - PRINTF_TEST( 5, "65535", "%hu", USHRT_MAX ); - PRINTF_TEST( 5, "65535", "%hu", (unsigned short)-1 ); - PRINTF_TEST( UINT_DIG, UINT_MAX_DEZ_STR, "%u", UINT_MAX ); - PRINTF_TEST( UINT_DIG, UINT_MAX_DEZ_STR, "%u", -1u ); - PRINTF_TEST( ULONG_DIG, ULONG_MAX_DEZ_STR, "%lu", ULONG_MAX ); - PRINTF_TEST( ULONG_DIG, ULONG_MAX_DEZ_STR, "%lu", -1ul ); - PRINTF_TEST( ULLONG_DIG, ULLONG_MAX_DEZ_STR, "%llu", ULLONG_MAX ); - PRINTF_TEST( ULLONG_DIG, ULLONG_MAX_DEZ_STR, "%llu", -1ull ); - PRINTF_TEST( (int)strlen( INT_HEXDIG ) + 1, "F" INT_HEXDIG, "%X", UINT_MAX ); - PRINTF_TEST( (int)strlen( INT_HEXDIG ) + 3, "0XF" INT_HEXDIG, "%#X", -1u ); - PRINTF_TEST( (int)strlen( INT_HEXDIG ) + 1, "f" INT_hexdig, "%x", UINT_MAX ); - PRINTF_TEST( (int)strlen( INT_HEXDIG ) + 3, "0xf" INT_hexdig, "%#x", -1u ); - PRINTF_TEST( (int)strlen( INT_OCTDIG ), INT_OCTDIG, "%o", UINT_MAX ); - PRINTF_TEST( (int)strlen( INT_OCTDIG ) + 1, "0" INT_OCTDIG, "%#o", -1u ); -#if 0 - /* TODO: This test case is broken, doesn't test what it was intended to. */ - PRINTF_TEST( 5, "%.0#o", "%.0#o", 0 ); -#endif - PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%+d", INT_MIN ); - PRINTF_TEST( INT_DIG + 1, "+" INT_MAX_DEZ_STR, "%+d", INT_MAX ); - PRINTF_TEST( 2, "+0", "%+d", 0 ); - PRINTF_TEST( UINT_DIG, UINT_MAX_DEZ_STR, "%+u", UINT_MAX ); - PRINTF_TEST( UINT_DIG, UINT_MAX_DEZ_STR, "%+u", -1u ); - PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "% d", INT_MIN ); - PRINTF_TEST( INT_DIG + 1, " " INT_MAX_DEZ_STR, "% d", INT_MAX ); - PRINTF_TEST( 2, " 0", "% d", 0 ); - PRINTF_TEST( UINT_DIG, UINT_MAX_DEZ_STR, "% u", UINT_MAX ); - PRINTF_TEST( UINT_DIG, UINT_MAX_DEZ_STR, "% u", -1u ); - PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%" INT_DIG_LESS1 "d", INT_MIN ); - PRINTF_TEST( INT_DIG, INT_MAX_DEZ_STR, "%" INT_DIG_LESS1 "d", INT_MAX ); - PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%" sym2s(INT_DIG) "d", INT_MIN ); - PRINTF_TEST( INT_DIG, INT_MAX_DEZ_STR, "%" sym2s(INT_DIG) "d", INT_MAX ); - PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%" INT_DIG_PLUS1 "d", INT_MIN ); - PRINTF_TEST( INT_DIG + 1, " " INT_MAX_DEZ_STR, "%" INT_DIG_PLUS1 "d", INT_MAX ); - PRINTF_TEST( INT_DIG + 2, " -" INT_MIN_DEZ_STR, "%" INT_DIG_PLUS2 "d", INT_MIN ); - PRINTF_TEST( INT_DIG + 2, " " INT_MAX_DEZ_STR, "%" INT_DIG_PLUS2 "d", INT_MAX ); - PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%-" INT_DIG_LESS1 "d", INT_MIN ); - PRINTF_TEST( INT_DIG, INT_MAX_DEZ_STR, "%-" INT_DIG_LESS1 "d", INT_MAX ); - PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%-" sym2s(INT_DIG) "d", INT_MIN ); - PRINTF_TEST( INT_DIG, INT_MAX_DEZ_STR, "%-" sym2s(INT_DIG) "d", INT_MAX ); - PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%-" INT_DIG_PLUS1 "d", INT_MIN ); - PRINTF_TEST( INT_DIG + 1, INT_MAX_DEZ_STR " ", "%-" INT_DIG_PLUS1 "d", INT_MAX ); - PRINTF_TEST( INT_DIG + 2, "-" INT_MIN_DEZ_STR " ", "%-" INT_DIG_PLUS2 "d", INT_MIN ); - PRINTF_TEST( INT_DIG + 2, INT_MAX_DEZ_STR " ", "%-" INT_DIG_PLUS2 "d", INT_MAX ); - PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%0" INT_DIG_LESS1 "d", INT_MIN ); - PRINTF_TEST( INT_DIG, INT_MAX_DEZ_STR, "%0" INT_DIG_LESS1 "d", INT_MAX ); - PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%0" sym2s(INT_DIG) "d", INT_MIN ); - PRINTF_TEST( INT_DIG, INT_MAX_DEZ_STR, "%0" sym2s(INT_DIG) "d", INT_MAX ); - PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%0" INT_DIG_PLUS1 "d", INT_MIN ); - PRINTF_TEST( INT_DIG + 1, "0" INT_MAX_DEZ_STR, "%0" INT_DIG_PLUS1 "d", INT_MAX ); - PRINTF_TEST( INT_DIG + 2, "-0" INT_MIN_DEZ_STR, "%0" INT_DIG_PLUS2 "d", INT_MIN ); - PRINTF_TEST( INT_DIG + 2, "00" INT_MAX_DEZ_STR, "%0" INT_DIG_PLUS2 "d", INT_MAX ); - PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%-0" INT_DIG_LESS1 "d", INT_MIN ); - PRINTF_TEST( INT_DIG, INT_MAX_DEZ_STR, "%-0" INT_DIG_LESS1 "d", INT_MAX ); - PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%-0" sym2s(INT_DIG) "d", INT_MIN ); - PRINTF_TEST( INT_DIG, INT_MAX_DEZ_STR, "%-0" sym2s(INT_DIG) "d", INT_MAX ); - PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%-0" INT_DIG_PLUS1 "d", INT_MIN ); - PRINTF_TEST( INT_DIG + 1, INT_MAX_DEZ_STR " ", "%-0" INT_DIG_PLUS1 "d", INT_MAX ); - PRINTF_TEST( INT_DIG + 2, "-" INT_MIN_DEZ_STR " ", "%-0" INT_DIG_PLUS2 "d", INT_MIN ); - PRINTF_TEST( INT_DIG + 2, INT_MAX_DEZ_STR " ", "%-0" INT_DIG_PLUS2 "d", INT_MAX ); - /* FIXME: This test not yet 32/64 bit agnostic */ - PRINTF_TEST( 30, " 00000000002147483647", "%030.20d", INT_MAX ); - PRINTF_TEST( (int)strlen( INT_HEXDIG ) + 1, "f" INT_hexdig, "%.6x", UINT_MAX ); - PRINTF_TEST( (int)strlen( INT_HEXDIG ) + 3, "0xf" INT_hexdig, "%#6.3x", UINT_MAX ); - PRINTF_TEST( (int)strlen( INT_HEXDIG ) + 3, "0xf" INT_hexdig, "%#3.6x", UINT_MAX ); - PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%.6d", INT_MIN ); - PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%6.3d", INT_MIN ); - PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%3.6d", INT_MIN ); - PRINTF_TEST( UINT_DIG, "0xf" INT_hexdig, "%#0.6x", UINT_MAX ); - PRINTF_TEST( UINT_DIG, "0xf" INT_hexdig, "%#06.3x", UINT_MAX ); - PRINTF_TEST( UINT_DIG, "0xf" INT_hexdig, "%#03.6x", UINT_MAX ); - PRINTF_TEST( INT_DIG, INT_MAX_DEZ_STR, "%#0.6d", INT_MAX ); - PRINTF_TEST( INT_DIG, INT_MAX_DEZ_STR, "%#06.3d", INT_MAX ); - PRINTF_TEST( INT_DIG, INT_MAX_DEZ_STR, "%#03.6d", INT_MAX ); - PRINTF_TEST( INT_DIG + 1, "+" INT_MAX_DEZ_STR, "%#+.6d", INT_MAX ); - PRINTF_TEST( INT_DIG + 1, "+" INT_MAX_DEZ_STR, "%#+6.3d", INT_MAX ); - PRINTF_TEST( INT_DIG + 1, "+" INT_MAX_DEZ_STR, "%#+3.6d", INT_MAX ); - PRINTF_TEST( INT_DIG + 1, "+" INT_MAX_DEZ_STR, "%+0.6d", INT_MAX ); - PRINTF_TEST( INT_DIG + 1, "+" INT_MAX_DEZ_STR, "%+06.3d", INT_MAX ); - PRINTF_TEST( INT_DIG + 1, "+" INT_MAX_DEZ_STR, "%+03.6d", INT_MAX ); -#ifndef TEST_CONVERSION_ONLY - PRINTF_TEST( INT_DIG + 2, "- " INT_MAX_DEZ_STR, "- %d", INT_MAX ); - PRINTF_TEST( INT_DIG * 2 + 6, "- " INT_MAX_DEZ_STR " % -" INT_MIN_DEZ_STR, "- %d %% %d", INT_MAX, INT_MIN ); -#endif - PRINTF_TEST( 1, "x", "%c", 'x' ); - PRINTF_TEST( 6, "abcdef", "%s", "abcdef" ); - /* FIXME: This test not yet 32/64 bit agnostic */ - PRINTF_TEST( 10, "0xdeadbeef", "%p", (void *)0xdeadbeef ); - PRINTF_TEST( 6, " 0x1", "%#6x", 1 ); -#ifndef TEST_CONVERSION_ONLY - { - int val1, val2; - PRINTF_TEST( 9, "123456789", "123456%n789%n", &val1, &val2 ); - TESTCASE( val1 == 6 ); - TESTCASE( val2 == 9 ); - } -#endif - } - /* PDCLIB-20: Verify "unusual" combinations of length and signedness */ - PRINTF_TEST( 1, "1", "%tu", (ptrdiff_t) 1); /* unsigned prtdiff_t */ - PRINTF_TEST( 2, "-1", "%jd", (intmax_t) -1); /* intmax_t */ - PRINTF_TEST( 1, "1", "%ju", (uintmax_t) 1); /* uintmax_t */ - PRINTF_TEST( 1, "1", "%zd", (size_t) 1); /* signed size_t */ - -/****************************************************************************** - * NOTE: The following test cases are imported from the Tyndur project. They * - * are therefore under the license of said project, not CC0. * - * As said code comprises test cases, it does not form part of the * - * final compiled library, and has no bearing on its licensing. * - * * - * See bug PDCLIB-6 for full details * - ******************************************************************************/ -/* - * Copyright (c) 2011 The tyndur Project. All rights reserved. - * - * This code is derived from software contributed to the tyndur Project - * by Kevin Wolf. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - { -#ifndef TEST_CONVERSION_ONLY - /* Ein String ohne alles */ - PRINTF_TEST(12, "Hallo heimur", "Hallo heimur"); -#endif - /* Einfache Konvertierungen */ - PRINTF_TEST(12, "Hallo heimur", "%s", "Hallo heimur"); - PRINTF_TEST(4, "1024", "%d", 1024); - PRINTF_TEST(5, "-1024", "%d", -1024); - PRINTF_TEST(4, "1024", "%i", 1024); - PRINTF_TEST(5, "-1024", "%i", -1024); - PRINTF_TEST(4, "1024", "%u", 1024u); - PRINTF_TEST(10, "4294966272", "%u", -1024u); - PRINTF_TEST(3, "777", "%o", 0777u); - PRINTF_TEST(11, "37777777001", "%o", -0777u); - PRINTF_TEST(8, "1234abcd", "%x", 0x1234abcdu); - PRINTF_TEST(8, "edcb5433", "%x", -0x1234abcdu); - PRINTF_TEST(8, "1234ABCD", "%X", 0x1234abcdu); - PRINTF_TEST(8, "EDCB5433", "%X", -0x1234abcdu); - PRINTF_TEST(1, "x", "%c", 'x'); - PRINTF_TEST(1, "%", "%%"); - /* Mit %c kann man auch Nullbytes ausgeben */ - PRINTF_TEST(1, "\0", "%c", '\0'); - /* Vorzeichen erzwingen (Flag +) */ - PRINTF_TEST(12, "Hallo heimur", "%+s", "Hallo heimur"); - PRINTF_TEST(5, "+1024", "%+d", 1024); - PRINTF_TEST(5, "-1024", "%+d", -1024); - PRINTF_TEST(5, "+1024", "%+i", 1024); - PRINTF_TEST(5, "-1024", "%+i", -1024); - PRINTF_TEST(4, "1024", "%+u", 1024u); - PRINTF_TEST(10, "4294966272", "%+u", -1024u); - PRINTF_TEST(3, "777", "%+o", 0777u); - PRINTF_TEST(11, "37777777001", "%+o", -0777u); - PRINTF_TEST(8, "1234abcd", "%+x", 0x1234abcdu); - PRINTF_TEST(8, "edcb5433", "%+x", -0x1234abcdu); - PRINTF_TEST(8, "1234ABCD", "%+X", 0x1234abcdu); - PRINTF_TEST(8, "EDCB5433", "%+X", -0x1234abcdu); - PRINTF_TEST(1, "x", "%+c", 'x'); - /* Vorzeichenplatzhalter erzwingen (Flag ) */ - PRINTF_TEST(12, "Hallo heimur", "% s", "Hallo heimur"); - PRINTF_TEST(5, " 1024", "% d", 1024); - PRINTF_TEST(5, "-1024", "% d", -1024); - PRINTF_TEST(5, " 1024", "% i", 1024); - PRINTF_TEST(5, "-1024", "% i", -1024); - PRINTF_TEST(4, "1024", "% u", 1024u); - PRINTF_TEST(10, "4294966272", "% u", -1024u); - PRINTF_TEST(3, "777", "% o", 0777u); - PRINTF_TEST(11, "37777777001", "% o", -0777u); - PRINTF_TEST(8, "1234abcd", "% x", 0x1234abcdu); - PRINTF_TEST(8, "edcb5433", "% x", -0x1234abcdu); - PRINTF_TEST(8, "1234ABCD", "% X", 0x1234abcdu); - PRINTF_TEST(8, "EDCB5433", "% X", -0x1234abcdu); - PRINTF_TEST(1, "x", "% c", 'x'); - /* Flag + hat Vorrang über */ - PRINTF_TEST(12, "Hallo heimur", "%+ s", "Hallo heimur"); - PRINTF_TEST(5, "+1024", "%+ d", 1024); - PRINTF_TEST(5, "-1024", "%+ d", -1024); - PRINTF_TEST(5, "+1024", "%+ i", 1024); - PRINTF_TEST(5, "-1024", "%+ i", -1024); - PRINTF_TEST(4, "1024", "%+ u", 1024u); - PRINTF_TEST(10, "4294966272", "%+ u", -1024u); - PRINTF_TEST(3, "777", "%+ o", 0777u); - PRINTF_TEST(11, "37777777001", "%+ o", -0777u); - PRINTF_TEST(8, "1234abcd", "%+ x", 0x1234abcdu); - PRINTF_TEST(8, "edcb5433", "%+ x", -0x1234abcdu); - PRINTF_TEST(8, "1234ABCD", "%+ X", 0x1234abcdu); - PRINTF_TEST(8, "EDCB5433", "%+ X", -0x1234abcdu); - PRINTF_TEST(1, "x", "%+ c", 'x'); - /* Alternative Form */ - PRINTF_TEST(4, "0777", "%#o", 0777u); - PRINTF_TEST(12, "037777777001", "%#o", -0777u); - PRINTF_TEST(10, "0x1234abcd", "%#x", 0x1234abcdu); - PRINTF_TEST(10, "0xedcb5433", "%#x", -0x1234abcdu); - PRINTF_TEST(10, "0X1234ABCD", "%#X", 0x1234abcdu); - PRINTF_TEST(10, "0XEDCB5433", "%#X", -0x1234abcdu); - PRINTF_TEST(1, "0", "%#o", 0u); - PRINTF_TEST(1, "0", "%#x", 0u); - PRINTF_TEST(1, "0", "%#X", 0u); - /* Feldbreite: Kleiner als Ausgabe */ - PRINTF_TEST(12, "Hallo heimur", "%1s", "Hallo heimur"); - PRINTF_TEST(4, "1024", "%1d", 1024); - PRINTF_TEST(5, "-1024", "%1d", -1024); - PRINTF_TEST(4, "1024", "%1i", 1024); - PRINTF_TEST(5, "-1024", "%1i", -1024); - PRINTF_TEST(4, "1024", "%1u", 1024u); - PRINTF_TEST(10, "4294966272", "%1u", -1024u); - PRINTF_TEST(3, "777", "%1o", 0777u); - PRINTF_TEST(11, "37777777001", "%1o", -0777u); - PRINTF_TEST(8, "1234abcd", "%1x", 0x1234abcdu); - PRINTF_TEST(8, "edcb5433", "%1x", -0x1234abcdu); - PRINTF_TEST(8, "1234ABCD", "%1X", 0x1234abcdu); - PRINTF_TEST(8, "EDCB5433", "%1X", -0x1234abcdu); - PRINTF_TEST(1, "x", "%1c", 'x'); - /* Feldbreite: Größer als Ausgabe */ - PRINTF_TEST(20, " Hallo", "%20s", "Hallo"); - PRINTF_TEST(20, " 1024", "%20d", 1024); - PRINTF_TEST(20, " -1024", "%20d", -1024); - PRINTF_TEST(20, " 1024", "%20i", 1024); - PRINTF_TEST(20, " -1024", "%20i", -1024); - PRINTF_TEST(20, " 1024", "%20u", 1024u); - PRINTF_TEST(20, " 4294966272", "%20u", -1024u); - PRINTF_TEST(20, " 777", "%20o", 0777u); - PRINTF_TEST(20, " 37777777001", "%20o", -0777u); - PRINTF_TEST(20, " 1234abcd", "%20x", 0x1234abcdu); - PRINTF_TEST(20, " edcb5433", "%20x", -0x1234abcdu); - PRINTF_TEST(20, " 1234ABCD", "%20X", 0x1234abcdu); - PRINTF_TEST(20, " EDCB5433", "%20X", -0x1234abcdu); - PRINTF_TEST(20, " x", "%20c", 'x'); - /* Feldbreite: Linksbündig */ - PRINTF_TEST(20, "Hallo ", "%-20s", "Hallo"); - PRINTF_TEST(20, "1024 ", "%-20d", 1024); - PRINTF_TEST(20, "-1024 ", "%-20d", -1024); - PRINTF_TEST(20, "1024 ", "%-20i", 1024); - PRINTF_TEST(20, "-1024 ", "%-20i", -1024); - PRINTF_TEST(20, "1024 ", "%-20u", 1024u); - PRINTF_TEST(20, "4294966272 ", "%-20u", -1024u); - PRINTF_TEST(20, "777 ", "%-20o", 0777u); - PRINTF_TEST(20, "37777777001 ", "%-20o", -0777u); - PRINTF_TEST(20, "1234abcd ", "%-20x", 0x1234abcdu); - PRINTF_TEST(20, "edcb5433 ", "%-20x", -0x1234abcdu); - PRINTF_TEST(20, "1234ABCD ", "%-20X", 0x1234abcdu); - PRINTF_TEST(20, "EDCB5433 ", "%-20X", -0x1234abcdu); - PRINTF_TEST(20, "x ", "%-20c", 'x'); - /* Feldbreite: Padding mit 0 */ - PRINTF_TEST(20, "00000000000000001024", "%020d", 1024); - PRINTF_TEST(20, "-0000000000000001024", "%020d", -1024); - PRINTF_TEST(20, "00000000000000001024", "%020i", 1024); - PRINTF_TEST(20, "-0000000000000001024", "%020i", -1024); - PRINTF_TEST(20, "00000000000000001024", "%020u", 1024u); - PRINTF_TEST(20, "00000000004294966272", "%020u", -1024u); - PRINTF_TEST(20, "00000000000000000777", "%020o", 0777u); - PRINTF_TEST(20, "00000000037777777001", "%020o", -0777u); - PRINTF_TEST(20, "0000000000001234abcd", "%020x", 0x1234abcdu); - PRINTF_TEST(20, "000000000000edcb5433", "%020x", -0x1234abcdu); - PRINTF_TEST(20, "0000000000001234ABCD", "%020X", 0x1234abcdu); - PRINTF_TEST(20, "000000000000EDCB5433", "%020X", -0x1234abcdu); - /* Feldbreite: Padding und alternative Form */ - PRINTF_TEST(20, " 0777", "%#20o", 0777u); - PRINTF_TEST(20, " 037777777001", "%#20o", -0777u); - PRINTF_TEST(20, " 0x1234abcd", "%#20x", 0x1234abcdu); - PRINTF_TEST(20, " 0xedcb5433", "%#20x", -0x1234abcdu); - PRINTF_TEST(20, " 0X1234ABCD", "%#20X", 0x1234abcdu); - PRINTF_TEST(20, " 0XEDCB5433", "%#20X", -0x1234abcdu); - PRINTF_TEST(20, "00000000000000000777", "%#020o", 0777u); - PRINTF_TEST(20, "00000000037777777001", "%#020o", -0777u); - PRINTF_TEST(20, "0x00000000001234abcd", "%#020x", 0x1234abcdu); - PRINTF_TEST(20, "0x0000000000edcb5433", "%#020x", -0x1234abcdu); - PRINTF_TEST(20, "0X00000000001234ABCD", "%#020X", 0x1234abcdu); - PRINTF_TEST(20, "0X0000000000EDCB5433", "%#020X", -0x1234abcdu); - /* Feldbreite: - hat Vorrang vor 0 */ - PRINTF_TEST(20, "Hallo ", "%0-20s", "Hallo"); - PRINTF_TEST(20, "1024 ", "%0-20d", 1024); - PRINTF_TEST(20, "-1024 ", "%0-20d", -1024); - PRINTF_TEST(20, "1024 ", "%0-20i", 1024); - PRINTF_TEST(20, "-1024 ", "%0-20i", -1024); - PRINTF_TEST(20, "1024 ", "%0-20u", 1024u); - PRINTF_TEST(20, "4294966272 ", "%0-20u", -1024u); - PRINTF_TEST(20, "777 ", "%-020o", 0777u); - PRINTF_TEST(20, "37777777001 ", "%-020o", -0777u); - PRINTF_TEST(20, "1234abcd ", "%-020x", 0x1234abcdu); - PRINTF_TEST(20, "edcb5433 ", "%-020x", -0x1234abcdu); - PRINTF_TEST(20, "1234ABCD ", "%-020X", 0x1234abcdu); - PRINTF_TEST(20, "EDCB5433 ", "%-020X", -0x1234abcdu); - PRINTF_TEST(20, "x ", "%-020c", 'x'); - /* Feldbreite: Aus Parameter */ - PRINTF_TEST(20, " Hallo", "%*s", 20, "Hallo"); - PRINTF_TEST(20, " 1024", "%*d", 20, 1024); - PRINTF_TEST(20, " -1024", "%*d", 20, -1024); - PRINTF_TEST(20, " 1024", "%*i", 20, 1024); - PRINTF_TEST(20, " -1024", "%*i", 20, -1024); - PRINTF_TEST(20, " 1024", "%*u", 20, 1024u); - PRINTF_TEST(20, " 4294966272", "%*u", 20, -1024u); - PRINTF_TEST(20, " 777", "%*o", 20, 0777u); - PRINTF_TEST(20, " 37777777001", "%*o", 20, -0777u); - PRINTF_TEST(20, " 1234abcd", "%*x", 20, 0x1234abcdu); - PRINTF_TEST(20, " edcb5433", "%*x", 20, -0x1234abcdu); - PRINTF_TEST(20, " 1234ABCD", "%*X", 20, 0x1234abcdu); - PRINTF_TEST(20, " EDCB5433", "%*X", 20, -0x1234abcdu); - PRINTF_TEST(20, " x", "%*c", 20, 'x'); - /* Präzision / Mindestanzahl von Ziffern */ - PRINTF_TEST(12, "Hallo heimur", "%.20s", "Hallo heimur"); - PRINTF_TEST(20, "00000000000000001024", "%.20d", 1024); - PRINTF_TEST(21, "-00000000000000001024", "%.20d", -1024); - PRINTF_TEST(20, "00000000000000001024", "%.20i", 1024); - PRINTF_TEST(21, "-00000000000000001024", "%.20i", -1024); - PRINTF_TEST(20, "00000000000000001024", "%.20u", 1024u); - PRINTF_TEST(20, "00000000004294966272", "%.20u", -1024u); - PRINTF_TEST(20, "00000000000000000777", "%.20o", 0777u); - PRINTF_TEST(20, "00000000037777777001", "%.20o", -0777u); - PRINTF_TEST(20, "0000000000001234abcd", "%.20x", 0x1234abcdu); - PRINTF_TEST(20, "000000000000edcb5433", "%.20x", -0x1234abcdu); - PRINTF_TEST(20, "0000000000001234ABCD", "%.20X", 0x1234abcdu); - PRINTF_TEST(20, "000000000000EDCB5433", "%.20X", -0x1234abcdu); - /* Feldbreite und Präzision */ - PRINTF_TEST(20, " Hallo", "%20.5s", "Hallo heimur"); - PRINTF_TEST(20, " 01024", "%20.5d", 1024); - PRINTF_TEST(20, " -01024", "%20.5d", -1024); - PRINTF_TEST(20, " 01024", "%20.5i", 1024); - PRINTF_TEST(20, " -01024", "%20.5i", -1024); - PRINTF_TEST(20, " 01024", "%20.5u", 1024u); - PRINTF_TEST(20, " 4294966272", "%20.5u", -1024u); - PRINTF_TEST(20, " 00777", "%20.5o", 0777u); - PRINTF_TEST(20, " 37777777001", "%20.5o", -0777u); - PRINTF_TEST(20, " 1234abcd", "%20.5x", 0x1234abcdu); - PRINTF_TEST(20, " 00edcb5433", "%20.10x", -0x1234abcdu); - PRINTF_TEST(20, " 1234ABCD", "%20.5X", 0x1234abcdu); - PRINTF_TEST(20, " 00EDCB5433", "%20.10X", -0x1234abcdu); - /* Präzision: 0 wird ignoriert */ - PRINTF_TEST(20, " Hallo", "%020.5s", "Hallo heimur"); - PRINTF_TEST(20, " 01024", "%020.5d", 1024); - PRINTF_TEST(20, " -01024", "%020.5d", -1024); - PRINTF_TEST(20, " 01024", "%020.5i", 1024); - PRINTF_TEST(20, " -01024", "%020.5i", -1024); - PRINTF_TEST(20, " 01024", "%020.5u", 1024u); - PRINTF_TEST(20, " 4294966272", "%020.5u", -1024u); - PRINTF_TEST(20, " 00777", "%020.5o", 0777u); - PRINTF_TEST(20, " 37777777001", "%020.5o", -0777u); - PRINTF_TEST(20, " 1234abcd", "%020.5x", 0x1234abcdu); - PRINTF_TEST(20, " 00edcb5433", "%020.10x", -0x1234abcdu); - PRINTF_TEST(20, " 1234ABCD", "%020.5X", 0x1234abcdu); - PRINTF_TEST(20, " 00EDCB5433", "%020.10X", -0x1234abcdu); - /* Präzision 0 */ - PRINTF_TEST(0, "", "%.0s", "Hallo heimur"); - PRINTF_TEST(20, " ", "%20.0s", "Hallo heimur"); - PRINTF_TEST(0, "", "%.s", "Hallo heimur"); - PRINTF_TEST(20, " ", "%20.s", "Hallo heimur"); - PRINTF_TEST(20, " 1024", "%20.0d", 1024); - PRINTF_TEST(20, " -1024", "%20.d", -1024); - PRINTF_TEST(20, " ", "%20.d", 0); - PRINTF_TEST(20, " 1024", "%20.0i", 1024); - PRINTF_TEST(20, " -1024", "%20.i", -1024); - PRINTF_TEST(20, " ", "%20.i", 0); - PRINTF_TEST(20, " 1024", "%20.u", 1024u); - PRINTF_TEST(20, " 4294966272", "%20.0u", -1024u); - PRINTF_TEST(20, " ", "%20.u", 0u); - PRINTF_TEST(20, " 777", "%20.o", 0777u); - PRINTF_TEST(20, " 37777777001", "%20.0o", -0777u); - PRINTF_TEST(20, " ", "%20.o", 0u); - PRINTF_TEST(20, " 1234abcd", "%20.x", 0x1234abcdu); - PRINTF_TEST(20, " edcb5433", "%20.0x", -0x1234abcdu); - PRINTF_TEST(20, " ", "%20.x", 0u); - PRINTF_TEST(20, " 1234ABCD", "%20.X", 0x1234abcdu); - PRINTF_TEST(20, " EDCB5433", "%20.0X", -0x1234abcdu); - PRINTF_TEST(20, " ", "%20.X", 0u); - /* Negative Präzision wird ignoriert */ - /* XXX glibc tut nicht, was ich erwartet habe, vorerst deaktiviert... */ - /* - * Präzision und Feldbreite aus Parameter. - * + hat Vorrang vor , - hat Vorrang vor 0 (das eh ignoriert wird, - * weil eine Präzision angegeben ist) - */ - PRINTF_TEST(20, "Hallo ", "% -0+*.*s", 20, 5, "Hallo heimur"); - PRINTF_TEST(20, "+01024 ", "% -0+*.*d", 20, 5, 1024); - PRINTF_TEST(20, "-01024 ", "% -0+*.*d", 20, 5, -1024); - PRINTF_TEST(20, "+01024 ", "% -0+*.*i", 20, 5, 1024); - PRINTF_TEST(20, "-01024 ", "% 0-+*.*i", 20, 5, -1024); - PRINTF_TEST(20, "01024 ", "% 0-+*.*u", 20, 5, 1024u); - PRINTF_TEST(20, "4294966272 ", "% 0-+*.*u", 20, 5, -1024u); - PRINTF_TEST(20, "00777 ", "%+ -0*.*o", 20, 5, 0777u); - PRINTF_TEST(20, "37777777001 ", "%+ -0*.*o", 20, 5, -0777u); - PRINTF_TEST(20, "1234abcd ", "%+ -0*.*x", 20, 5, 0x1234abcdu); - PRINTF_TEST(20, "00edcb5433 ", "%+ -0*.*x", 20, 10, -0x1234abcdu); - PRINTF_TEST(20, "1234ABCD ", "% -+0*.*X", 20, 5, 0x1234abcdu); - PRINTF_TEST(20, "00EDCB5433 ", "% -+0*.*X", 20, 10, -0x1234abcdu); -#pragma clang diagnostic pop - } - -#undef PRINTF_TEST -/******************************************************************************/ diff --git a/src/libraries/libc/tests/scanf_testcases.h b/src/libraries/libc/tests/scanf_testcases.h deleted file mode 100644 index 2ff2471..0000000 --- a/src/libraries/libc/tests/scanf_testcases.h +++ /dev/null @@ -1,96 +0,0 @@ -#define SCANF_TEST( expected_rc, input_string, ... ) do { \ - TEST_RESULTS += DO_TESTSCANF(IMPLFILE, __FILE__, __LINE__, expected_rc, input_string, __VA_ARGS__); \ - } while (0); - -{ - char buffer[100]; - int i; - unsigned int u; - int * p; - /* basic: reading of three-char string */ - SCANF_TEST( 1, "foo", "%3c", buffer ); - TESTCASE( memcmp( buffer, "foo", 3 ) == 0 ); -#ifndef TEST_CONVERSION_ONLY - /* %% for single % */ - SCANF_TEST( 1, "%x", "%%%c", buffer ); - TESTCASE( buffer[0] == 'x' ); - /* * to skip assignment */ - SCANF_TEST( 1, "3xfoo", "%*dx%3c", buffer ); - TESTCASE( memcmp( buffer, "foo", 3 ) == 0 ); -#endif - /* domain testing on 'int' type */ - SCANF_TEST( 1, "-" INT_MIN_DEZ_STR, "%d", &i ); - TESTCASE( i == INT_MIN ); - SCANF_TEST( 1, INT_MAX_DEZ_STR, "%d", &i ); - TESTCASE( i == INT_MAX ); - SCANF_TEST( 1, "-1", "%d", &i ); - TESTCASE( i == -1 ); - SCANF_TEST( 1, "0", "%d", &i ); - TESTCASE( i == 0 ); - SCANF_TEST( 1, "1", "%d", &i ); - TESTCASE( i == 1 ); - SCANF_TEST( 1, "-" INT_MIN_DEZ_STR, "%i", &i ); - TESTCASE( i == INT_MIN ); - SCANF_TEST( 1, INT_MAX_DEZ_STR, "%i", &i ); - TESTCASE( i == INT_MAX ); - SCANF_TEST( 1, "-1", "%i", &i ); - TESTCASE( i == -1 ); - SCANF_TEST( 1, "0", "%i", &i ); - TESTCASE( i == 0 ); - SCANF_TEST( 1, "1", "%i", &i ); - TESTCASE( i == 1 ); - SCANF_TEST( 1, "0x7" INT_HEXDIG, "%i", &i ); - TESTCASE( i == INT_MAX ); - SCANF_TEST( 1, "0x0", "%i", &i ); - TESTCASE( i == 0 ); -#ifndef TEST_CONVERSION_ONLY - SCANF_TEST( 1, "00", "%i%n", &i, &u ); - TESTCASE( i == 0 ); - TESTCASE( u == 2 ); -#endif - /* domain testing on 'unsigned int' type */ - SCANF_TEST( 1, UINT_MAX_DEZ_STR, "%u", &u ); - TESTCASE( u == UINT_MAX ); - SCANF_TEST( 1, "0", "%u", &u ); - TESTCASE( u == 0 ); - SCANF_TEST( 1, "f" INT_HEXDIG, "%x", &u ); - TESTCASE( u == UINT_MAX ); - SCANF_TEST( 1, "7" INT_HEXDIG, "%x", &u ); - TESTCASE( u == INT_MAX ); - SCANF_TEST( 1, "0", "%o", &u ); - TESTCASE( u == 0 ); - SCANF_TEST( 1, INT_OCTDIG, "%o", &u ); - TESTCASE( u == UINT_MAX ); - /* testing %c */ - memset( buffer, '\0', 100 ); - SCANF_TEST( 1, "x", "%c", buffer ); - TESTCASE( memcmp( buffer, "x\0", 2 ) == 0 ); - /* testing %s */ - memset( buffer, '\0', 100 ); - SCANF_TEST( 1, "foo bar", "%s", buffer ); - TESTCASE( memcmp( buffer, "foo\0", 4 ) == 0 ); -#ifndef TEST_CONVERSION_ONLY - SCANF_TEST( 2, "foo bar baz", "%s %s %n", buffer, buffer + 4, &u ); - TESTCASE( u == 9 ); - TESTCASE( memcmp( buffer, "foo\0bar\0", 8 ) == 0 ); -#endif - /* testing %[ */ - SCANF_TEST( 1, "abcdefg", "%[cba]", buffer ); - TESTCASE( memcmp( buffer, "abc\0", 4 ) == 0 ); - /* testing %p */ - p = NULL; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wformat-pedantic" - sprintf( buffer, "%p", p ); - p = &i; - SCANF_TEST( 1, buffer, "%p", &p ); - TESTCASE( p == NULL ); - p = &i; - sprintf( buffer, "%p", p ); - p = NULL; - SCANF_TEST( 1, buffer, "%p", &p ); - TESTCASE( p == &i ); -#pragma clang diagnostic pop -} - -#undef SCANF_TEST diff --git a/src/libraries/libc/tests/test_assert.c b/src/libraries/libc/tests/test_assert.c deleted file mode 100644 index cf4763e..0000000 --- a/src/libraries/libc/tests/test_assert.c +++ /dev/null @@ -1,50 +0,0 @@ -#include "_PDCLIB_test.h" - -#define NDEBUG -#include - -#define enabled_assert( expression ) ( ( expression ) ? (void) 0 \ - : _PDCLIB_assert( "Assertion failed: " #expression \ - ", function ", __func__, \ - ", file " __FILE__ \ - ", line " _PDCLIB_symbol2string( __LINE__ ) \ - "." _PDCLIB_endl ) ) - -static int EXPECTED = 0; -static void aborthandler( int sig ) -{ - _exit(!EXPECTED); -} - -static int assert_disabled_test( void ) -{ - int i = 0; - assert( i == 0 ); /* NDEBUG set, condition met */ - assert( i == 1 ); /* NDEBUG set, condition fails */ - return i; -} - -int assert_enabled_test(int val) -{ - enabled_assert(val); - return val; -} - -START_TEST( assert ) -{ - sighandler_t sh = signal(SIGABRT, &aborthandler); - TESTCASE( sh != SIG_ERR ); - - TESTCASE( assert_disabled_test() == 0 ); - TESTCASE( assert_enabled_test(1) ); /* NDEBUG not set, condition met */ - - EXPECTED = 1; - TESTCASE( assert_enabled_test(0) ); /* NDEBUG not set, condition fails - should abort */ -} -END_TEST - -START_SUITE( assert ) -{ - RUN_TEST( assert ); -} -END_SUITE diff --git a/src/libraries/libc/tests/test_ctype.c b/src/libraries/libc/tests/test_ctype.c deleted file mode 100644 index bf99f1e..0000000 --- a/src/libraries/libc/tests/test_ctype.c +++ /dev/null @@ -1,186 +0,0 @@ -#include "_PDCLIB_test.h" - -START_TEST( isalnum ) -{ - TESTCASE( isalnum( 'a' ) ); - TESTCASE( isalnum( 'z' ) ); - TESTCASE( isalnum( 'A' ) ); - TESTCASE( isalnum( 'Z' ) ); - TESTCASE( isalnum( '0' ) ); - TESTCASE( isalnum( '9' ) ); - TESTCASE( ! isalnum( ' ' ) ); - TESTCASE( ! isalnum( '\n' ) ); - TESTCASE( ! isalnum( '@' ) ); -} -END_TEST - -START_TEST( isalpha ) -{ - TESTCASE( isalpha( 'a' ) ); - TESTCASE( isalpha( 'z' ) ); - TESTCASE( ! isalpha( ' ' ) ); - TESTCASE( ! isalpha( '1' ) ); - TESTCASE( ! isalpha( '@' ) ); -} -END_TEST - -START_TEST( isblank ) -{ - TESTCASE( isblank( ' ' ) ); - TESTCASE( isblank( '\t' ) ); - TESTCASE( ! isblank( '\v' ) ); - TESTCASE( ! isblank( '\r' ) ); - TESTCASE( ! isblank( 'x' ) ); - TESTCASE( ! isblank( '@' ) ); -} -END_TEST - -START_TEST( iscntrl ) -{ - TESTCASE( iscntrl( '\a' ) ); - TESTCASE( iscntrl( '\b' ) ); - TESTCASE( iscntrl( '\n' ) ); - TESTCASE( ! iscntrl( ' ' ) ); -} -END_TEST - -START_TEST( isdigit ) -{ - TESTCASE( isdigit( '0' ) ); - TESTCASE( isdigit( '9' ) ); - TESTCASE( ! isdigit( ' ' ) ); - TESTCASE( ! isdigit( 'a' ) ); - TESTCASE( ! isdigit( '@' ) ); -} -END_TEST - -START_TEST( isgraph ) -{ - TESTCASE( isgraph( 'a' ) ); - TESTCASE( isgraph( 'z' ) ); - TESTCASE( isgraph( 'A' ) ); - TESTCASE( isgraph( 'Z' ) ); - TESTCASE( isgraph( '@' ) ); - TESTCASE( ! isgraph( '\t' ) ); - TESTCASE( ! isgraph( '\0' ) ); - TESTCASE( ! isgraph( ' ' ) ); -} -END_TEST - -START_TEST( islower ) -{ - TESTCASE( islower( 'a' ) ); - TESTCASE( islower( 'z' ) ); - TESTCASE( ! islower( 'A' ) ); - TESTCASE( ! islower( 'Z' ) ); - TESTCASE( ! islower( ' ' ) ); - TESTCASE( ! islower( '@' ) ); -} -END_TEST - -START_TEST( isprint ) -{ - TESTCASE( isprint( 'a' ) ); - TESTCASE( isprint( 'z' ) ); - TESTCASE( isprint( 'A' ) ); - TESTCASE( isprint( 'Z' ) ); - TESTCASE( isprint( '@' ) ); - TESTCASE( ! isprint( '\t' ) ); - TESTCASE( ! isprint( '\0' ) ); - TESTCASE( isprint( ' ' ) ); -} -END_TEST - -START_TEST( ispunct ) -{ - TESTCASE( ! ispunct( 'a' ) ); - TESTCASE( ! ispunct( 'z' ) ); - TESTCASE( ! ispunct( 'A' ) ); - TESTCASE( ! ispunct( 'Z' ) ); - TESTCASE( ispunct( '@' ) ); - TESTCASE( ispunct( '.' ) ); - TESTCASE( ! ispunct( '\t' ) ); - TESTCASE( ! ispunct( '\0' ) ); - TESTCASE( ! ispunct( ' ' ) ); -} -END_TEST - -START_TEST( isspace ) -{ - TESTCASE( isspace( ' ' ) ); - TESTCASE( isspace( '\f' ) ); - TESTCASE( isspace( '\n' ) ); - TESTCASE( isspace( '\r' ) ); - TESTCASE( isspace( '\t' ) ); - TESTCASE( isspace( '\v' ) ); - TESTCASE( ! isspace( 'a' ) ); -} -END_TEST - -START_TEST( isupper ) -{ - TESTCASE( isupper( 'A' ) ); - TESTCASE( isupper( 'Z' ) ); - TESTCASE( ! isupper( 'a' ) ); - TESTCASE( ! isupper( 'z' ) ); - TESTCASE( ! isupper( ' ' ) ); - TESTCASE( ! isupper( '@' ) ); -} -END_TEST - -START_TEST( isxdigit ) -{ - TESTCASE( isxdigit( '0' ) ); - TESTCASE( isxdigit( '9' ) ); - TESTCASE( isxdigit( 'a' ) ); - TESTCASE( isxdigit( 'f' ) ); - TESTCASE( ! isxdigit( 'g' ) ); - TESTCASE( isxdigit( 'A' ) ); - TESTCASE( isxdigit( 'F' ) ); - TESTCASE( ! isxdigit( 'G' ) ); - TESTCASE( ! isxdigit( '@' ) ); - TESTCASE( ! isxdigit( ' ' ) ); -} -END_TEST - -START_TEST( tolower ) -{ - TESTCASE( tolower( 'A' ) == 'a' ); - TESTCASE( tolower( 'Z' ) == 'z' ); - TESTCASE( tolower( 'a' ) == 'a' ); - TESTCASE( tolower( 'z' ) == 'z' ); - TESTCASE( tolower( '@' ) == '@' ); - TESTCASE( tolower( '[' ) == '[' ); -} -END_TEST - -START_TEST( toupper ) -{ - TESTCASE( toupper( 'a' ) == 'A' ); - TESTCASE( toupper( 'z' ) == 'Z' ); - TESTCASE( toupper( 'A' ) == 'A' ); - TESTCASE( toupper( 'Z' ) == 'Z' ); - TESTCASE( toupper( '@' ) == '@' ); - TESTCASE( toupper( '[' ) == '[' ); -} -END_TEST - - -START_SUITE( ctype ) -{ - RUN_TEST( isalnum ); - RUN_TEST( isalpha ); - RUN_TEST( isblank ); - RUN_TEST( iscntrl ); - RUN_TEST( isdigit ); - RUN_TEST( isgraph ); - RUN_TEST( islower ); - RUN_TEST( isprint ); - RUN_TEST( ispunct ); - RUN_TEST( isspace ); - RUN_TEST( isupper ); - RUN_TEST( isxdigit ); - RUN_TEST( tolower ); - RUN_TEST( toupper ); -} -END_SUITE diff --git a/src/libraries/libc/tests/test_internal.c b/src/libraries/libc/tests/test_internal.c deleted file mode 100644 index ba95658..0000000 --- a/src/libraries/libc/tests/test_internal.c +++ /dev/null @@ -1,724 +0,0 @@ -#include "_PDCLIB_test.h" -#include "_PDCLIB_iotest.h" -#include - -START_TEST( atomax ) -{ - /* basic functionality */ - TESTCASE( _PDCLIB_atomax( "123" ) == 123 ); - /* testing skipping of leading whitespace and trailing garbage */ - TESTCASE( _PDCLIB_atomax( " \n\v\t\f123xyz" ) == 123 ); -} -END_TEST - -START_TEST( digits ) -{ - TESTCASE( strcmp( _PDCLIB_digits, "0123456789abcdefghijklmnopqrstuvwxyz" ) == 0 ); - TESTCASE( strcmp( _PDCLIB_Xdigits, "0123456789ABCDEF" ) == 0 ); -} -END_TEST - -START_TEST( filemode ) -{ - TESTCASE( _PDCLIB_filemode( "r" ) == _PDCLIB_FREAD ); - TESTCASE( _PDCLIB_filemode( "w" ) == _PDCLIB_FWRITE ); - TESTCASE( _PDCLIB_filemode( "a" ) == ( _PDCLIB_FAPPEND | _PDCLIB_FWRITE ) ); - TESTCASE( _PDCLIB_filemode( "r+" ) == ( _PDCLIB_FREAD | _PDCLIB_FRW ) ); - TESTCASE( _PDCLIB_filemode( "w+" ) == ( _PDCLIB_FWRITE | _PDCLIB_FRW ) ); - TESTCASE( _PDCLIB_filemode( "a+" ) == ( _PDCLIB_FAPPEND | _PDCLIB_FWRITE | _PDCLIB_FRW ) ); - TESTCASE( _PDCLIB_filemode( "rb" ) == ( _PDCLIB_FREAD | _PDCLIB_FBIN ) ); - TESTCASE( _PDCLIB_filemode( "wb" ) == ( _PDCLIB_FWRITE | _PDCLIB_FBIN ) ); - TESTCASE( _PDCLIB_filemode( "ab" ) == ( _PDCLIB_FAPPEND | _PDCLIB_FWRITE | _PDCLIB_FBIN ) ); - TESTCASE( _PDCLIB_filemode( "r+b" ) == ( _PDCLIB_FREAD | _PDCLIB_FRW | _PDCLIB_FBIN ) ); - TESTCASE( _PDCLIB_filemode( "w+b" ) == ( _PDCLIB_FWRITE | _PDCLIB_FRW | _PDCLIB_FBIN ) ); - TESTCASE( _PDCLIB_filemode( "a+b" ) == ( _PDCLIB_FAPPEND | _PDCLIB_FWRITE | _PDCLIB_FRW | _PDCLIB_FBIN ) ); - TESTCASE( _PDCLIB_filemode( "rb+" ) == ( _PDCLIB_FREAD | _PDCLIB_FRW | _PDCLIB_FBIN ) ); - TESTCASE( _PDCLIB_filemode( "wb+" ) == ( _PDCLIB_FWRITE | _PDCLIB_FRW | _PDCLIB_FBIN ) ); - TESTCASE( _PDCLIB_filemode( "ab+" ) == ( _PDCLIB_FAPPEND | _PDCLIB_FWRITE | _PDCLIB_FRW | _PDCLIB_FBIN ) ); - TESTCASE( _PDCLIB_filemode( "x" ) == 0 ); - TESTCASE( _PDCLIB_filemode( "r++" ) == 0 ); - TESTCASE( _PDCLIB_filemode( "wbb" ) == 0 ); - TESTCASE( _PDCLIB_filemode( "a+bx" ) == 0 ); -} -END_TEST - -START_TEST( is_leap ) -{ - /* 1901 not leap */ - TESTCASE( ! _PDCLIB_is_leap( 1 ) ); - /* 1904 leap */ - TESTCASE( _PDCLIB_is_leap( 4 ) ); - /* 1900 not leap */ - TESTCASE( ! _PDCLIB_is_leap( 0 ) ); - /* 2000 leap */ - TESTCASE( _PDCLIB_is_leap( 100 ) ); -} -END_TEST - -START_TEST( load_lc_ctype ) -{ - FILE * fh = fopen( "test_ctype.dat", "wb" ); - TESTCASE_REQUIRE( fh != NULL ); - /* For test purposes, let's set up a charset that only has the hex digits */ - /* 0x00..0x09 - digits */ - /* 0x11..0x16 - Xdigits */ - /* 0x21..0x26 - xdigits */ - TESTCASE( j6libc_fprintf( fh, "%x %x\n", 0x00, 0x09 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x %x\n", 0x11, 0x16, 0x21, 0x26 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", _PDCLIB_CTYPE_GRAPH, 0x00, 0x00 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", _PDCLIB_CTYPE_GRAPH, 0x01, 0x01 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", _PDCLIB_CTYPE_GRAPH, 0x02, 0x02 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", _PDCLIB_CTYPE_GRAPH, 0x03, 0x03 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", _PDCLIB_CTYPE_GRAPH, 0x04, 0x04 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", _PDCLIB_CTYPE_GRAPH, 0x05, 0x05 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", _PDCLIB_CTYPE_GRAPH, 0x06, 0x06 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", _PDCLIB_CTYPE_GRAPH, 0x07, 0x07 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", _PDCLIB_CTYPE_GRAPH, 0x08, 0x08 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", _PDCLIB_CTYPE_GRAPH, 0x09, 0x09 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x0A, 0x0A ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x0B, 0x0B ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x0C, 0x0C ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x0D, 0x0D ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x0E, 0x0E ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x0F, 0x0F ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x10, 0x10 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER, 0x11, 0x11 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER, 0x12, 0x12 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER, 0x13, 0x13 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER, 0x14, 0x14 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER, 0x15, 0x15 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_UPPER, 0x16, 0x16 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x17, 0x17 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x18, 0x18 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x19, 0x19 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x1A, 0x1A ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x1B, 0x1B ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x1C, 0x1C ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x1D, 0x1D ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x1E, 0x1E ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x1F, 0x1F ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x20, 0x20 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER, 0x21, 0x21 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER, 0x22, 0x22 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER, 0x23, 0x23 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER, 0x24, 0x24 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER, 0x25, 0x25 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_LOWER, 0x26, 0x26 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x27, 0x27 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x28, 0x28 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x29, 0x29 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x2A, 0x2A ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x2B, 0x2B ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x2C, 0x2C ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x2D, 0x2D ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x2E, 0x2E ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x2F, 0x2F ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x30, 0x30 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x31, 0x31 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x32, 0x32 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x33, 0x33 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x34, 0x34 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x35, 0x35 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x36, 0x36 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x37, 0x37 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x38, 0x38 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x39, 0x39 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x3A, 0x3A ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x3B, 0x3B ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x3C, 0x3C ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x3D, 0x3D ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x3E, 0x3E ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x3F, 0x3F ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x40, 0x40 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x41, 0x41 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x42, 0x42 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x43, 0x43 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x44, 0x44 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x45, 0x45 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x46, 0x46 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x47, 0x47 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x48, 0x48 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x49, 0x49 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x4A, 0x4A ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x4B, 0x4B ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x4C, 0x4C ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x4D, 0x4D ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x4E, 0x4E ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x4F, 0x4F ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x50, 0x50 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x51, 0x51 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x52, 0x52 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x53, 0x53 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x54, 0x54 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x55, 0x55 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x56, 0x56 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x57, 0x57 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x58, 0x58 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x59, 0x59 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x5A, 0x5A ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x5B, 0x5B ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x5C, 0x5C ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x5D, 0x5D ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x5E, 0x5E ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x5F, 0x5F ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x60, 0x60 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x61, 0x61 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x62, 0x62 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x63, 0x63 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x64, 0x64 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x65, 0x65 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x66, 0x66 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x67, 0x67 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x68, 0x68 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x69, 0x69 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x6A, 0x6A ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x6B, 0x6B ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x6C, 0x6C ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x6D, 0x6D ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x6E, 0x6E ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x6F, 0x6F ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x70, 0x70 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x71, 0x71 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x72, 0x72 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x73, 0x73 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x74, 0x74 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x75, 0x75 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x76, 0x76 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x77, 0x77 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x78, 0x78 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x79, 0x79 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x7A, 0x7A ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x7B, 0x7B ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x7C, 0x7C ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x7D, 0x7D ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x7E, 0x7E ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x7F, 0x7F ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x80, 0x80 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x81, 0x81 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x82, 0x82 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x83, 0x83 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x84, 0x84 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x85, 0x85 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x86, 0x86 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x87, 0x87 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x88, 0x88 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x89, 0x89 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x8A, 0x8A ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x8B, 0x8B ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x8C, 0x8C ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x8D, 0x8D ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x8E, 0x8E ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x8F, 0x8F ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x90, 0x90 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x91, 0x91 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x92, 0x92 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x93, 0x93 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x94, 0x94 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x95, 0x95 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x96, 0x96 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x97, 0x97 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x98, 0x98 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x99, 0x99 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x9A, 0x9A ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x9B, 0x9B ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x9C, 0x9C ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x9D, 0x9D ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x9E, 0x9E ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0x9F, 0x9F ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xA0, 0xA0 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xA1, 0xA1 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xA2, 0xA2 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xA3, 0xA3 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xA4, 0xA4 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xA5, 0xA5 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xA6, 0xA6 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xA7, 0xA7 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xA8, 0xA8 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xA9, 0xA9 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xAA, 0xAA ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xAB, 0xAB ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xAC, 0xAC ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xAD, 0xAD ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xAE, 0xAE ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xAF, 0xAF ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xB0, 0xB0 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xB1, 0xB1 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xB2, 0xB2 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xB3, 0xB3 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xB4, 0xB4 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xB5, 0xB5 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xB6, 0xB6 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xB7, 0xB7 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xB8, 0xB8 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xB9, 0xB9 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xBA, 0xBA ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xBB, 0xBB ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xBC, 0xBC ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xBD, 0xBD ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xBE, 0xBE ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xBF, 0xBF ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xC0, 0xC0 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xC1, 0xC1 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xC2, 0xC2 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xC3, 0xC3 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xC4, 0xC4 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xC5, 0xC5 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xC6, 0xC6 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xC7, 0xC7 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xC8, 0xC8 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xC9, 0xC9 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xCA, 0xCA ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xCB, 0xCB ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xCC, 0xCC ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xCD, 0xCD ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xCE, 0xCE ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xCF, 0xCF ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xD0, 0xD0 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xD1, 0xD1 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xD2, 0xD2 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xD3, 0xD3 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xD4, 0xD4 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xD5, 0xD5 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xD6, 0xD6 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xD7, 0xD7 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xD8, 0xD8 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xD9, 0xD9 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xDA, 0xDA ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xDB, 0xDB ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xDC, 0xDC ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xDD, 0xDD ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xDE, 0xDE ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xDF, 0xDF ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xE0, 0xE0 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xE1, 0xE1 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xE2, 0xE2 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xE3, 0xE3 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xE4, 0xE4 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xE5, 0xE5 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xE6, 0xE6 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xE7, 0xE7 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xE8, 0xE8 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xE9, 0xE9 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xEA, 0xEA ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xEB, 0xEB ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xEC, 0xEC ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xED, 0xED ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xEE, 0xEE ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xEF, 0xEF ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xF0, 0xF0 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xF1, 0xF1 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xF2, 0xF2 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xF3, 0xF3 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xF4, 0xF4 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xF5, 0xF5 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xF6, 0xF6 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xF7, 0xF7 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xF8, 0xF8 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xF9, 0xF9 ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xFA, 0xFA ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xFB, 0xFB ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xFC, 0xFC ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xFD, 0xFD ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xFE, 0xFE ) ); - TESTCASE( j6libc_fprintf( fh, "%x %x %x\n", 0x00, 0xFF, 0xFF) ); - fclose( fh ); - TESTCASE( _PDCLIB_load_lc_ctype( "./", "test" ) != NULL ); - remove( "test_ctype.dat" ); - /* - TESTCASE( isdigit( 0x00 ) && ! isxdigit( 0x00 ) && ! isalpha( 0x00 ) ); - TESTCASE( ! isdigit( 0x11 ) && isxdigit( 0x11 ) && isalpha( 0x11 ) && isupper( 0x11 ) && ! islower( 0x11 ) ); - TESTCASE( ! isdigit( 0x21 ) && isxdigit( 0x21 ) && isalpha( 0x21 ) && ! isupper( 0x11 ) && islower( 0x11 ) ); - */ -} -END_TEST - -START_TEST( load_lc_messages ) -{ - FILE * fh = fopen( "test_numeric.dat", "wb" ); - struct _PDCLIB_lc_lconv_numeric_t * lc; - - TESTCASE_REQUIRE( fh != NULL ); - - TESTCASE( fputs( ",\n.\n\n", fh ) != EOF ); - fclose( fh ); - TESTCASE( ( lc = _PDCLIB_load_lc_numeric( "./", "test" ) ) ); - remove( "test_numeric.dat" ); - TESTCASE( strcmp( lc->decimal_point, "," ) == 0 ); - TESTCASE( strcmp( lc->thousands_sep, "." ) == 0 ); - TESTCASE( strcmp( lc->grouping, "" ) == 0 ); -} -END_TEST - -START_TEST( load_lc_monetary ) -{ - FILE * fh = fopen( "test_monetary.dat", "wb" ); - struct _PDCLIB_lc_lconv_monetary_t * lc; - TESTCASE_REQUIRE( fh != NULL ); - - j6libc_fprintf( fh, "%s\n", "," ); /* mon_decimal_point */ - j6libc_fprintf( fh, "%s\n", "." ); /* mon_thousands_sep */ - j6libc_fprintf( fh, "%s\n", "3" ); /* mon_grouping */ - j6libc_fprintf( fh, "%s\n", "" ); /* positive_sign */ - j6libc_fprintf( fh, "%s\n", "-" ); /* negative_sign */ - j6libc_fprintf( fh, "%s\n", "\xa4" ); /* currency_symbol */ - j6libc_fprintf( fh, "%s\n", "EUR" ); /* int_curr_symbol */ - fputc( 2, fh ); /* frac_digits */ - fputc( 0, fh ); /* p_cs_precedes */ - fputc( 0, fh ); /* n_cs_precedes */ - fputc( 1, fh ); /* p_sep_by_space */ - fputc( 1, fh ); /* n_sep_by_space */ - fputc( 1, fh ); /* p_sign_posn */ - fputc( 1, fh ); /* n_sign_posn */ - fputc( 2, fh ); /* int_frac_digits */ - fputc( 0, fh ); /* int_p_cs_precedes */ - fputc( 0, fh ); /* int_n_cs_precedes */ - fputc( 1, fh ); /* int_p_sep_by_space */ - fputc( 1, fh ); /* int_n_sep_by_space */ - fputc( 1, fh ); /* int_p_sign_posn */ - fputc( 1, fh ); /* int_n_sign_posn */ - j6libc_fprintf( fh, "\n" ); - fclose( fh ); - TESTCASE( ( lc = _PDCLIB_load_lc_monetary( "./", "test" ) ) ); - remove( "test_monetary.dat" ); - TESTCASE( strcmp( lc->mon_decimal_point, "," ) == 0 ); - TESTCASE( strcmp( lc->mon_thousands_sep, "." ) == 0 ); - TESTCASE( strcmp( lc->mon_grouping, "3" ) == 0 ); - TESTCASE( strcmp( lc->positive_sign, "" ) == 0 ); - TESTCASE( strcmp( lc->negative_sign, "-" ) == 0 ); - TESTCASE( strcmp( lc->currency_symbol, "\xa4" ) == 0 ); - TESTCASE( strcmp( lc->int_curr_symbol, "EUR" ) == 0 ); - - TESTCASE( lc->frac_digits == 2 ); - TESTCASE( lc->p_cs_precedes == 0 ); - TESTCASE( lc->n_cs_precedes == 0 ); - TESTCASE( lc->p_sep_by_space == 1 ); - TESTCASE( lc->n_sep_by_space == 1 ); - TESTCASE( lc->p_sign_posn == 1 ); - TESTCASE( lc->n_sign_posn == 1 ); - TESTCASE( lc->int_frac_digits == 2 ); - TESTCASE( lc->int_p_cs_precedes == 0 ); - TESTCASE( lc->int_n_cs_precedes == 0 ); - TESTCASE( lc->int_p_sep_by_space == 1 ); - TESTCASE( lc->int_n_sep_by_space == 1 ); - TESTCASE( lc->int_p_sign_posn == 1 ); - TESTCASE( lc->int_n_sign_posn == 1 ); -} -END_TEST - -START_TEST( load_lc_numeric ) -{ - FILE * fh = fopen( "test_numeric.dat", "wb" ); - struct _PDCLIB_lc_lconv_numeric_t * lc; - TESTCASE_REQUIRE( fh != NULL ); - TESTCASE( fputs( ",\n.\n\n", fh ) != EOF ); - fclose( fh ); - TESTCASE( ( lc = _PDCLIB_load_lc_numeric( "./", "test" ) ) ); - remove( "test_numeric.dat" ); - TESTCASE( strcmp( lc->decimal_point, "," ) == 0 ); - TESTCASE( strcmp( lc->thousands_sep, "." ) == 0 ); - TESTCASE( strcmp( lc->grouping, "" ) == 0 ); -} -END_TEST - -START_TEST( load_lc_time ) -{ - FILE * fh = fopen( "test_time.dat", "wb" ); - struct _PDCLIB_lc_time_t * lc; - - TESTCASE_REQUIRE( fh != NULL ); - - /* month name abbreviation */ - TESTCASE( j6libc_fprintf( fh, "%s\n", "Jan" ) == 4 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "Feb" ) == 4 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "M\xe4r" ) == 4 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "Apr" ) == 4 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "Mai" ) == 4 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "Jun" ) == 4 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "Jul" ) == 4 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "Aug" ) == 4 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "Sep" ) == 4 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "Okt" ) == 4 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "Nov" ) == 4 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "Dez" ) == 4 ); - /* month name full */ - TESTCASE( j6libc_fprintf( fh, "%s\n", "Januar" ) == 7 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "Februar" ) == 8 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "M\xe4rz" ) == 5 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "April" ) == 6 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "Mai" ) == 4 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "Juni" ) == 5 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "Juli" ) == 5 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "August" ) == 7 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "September" ) == 10 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "Oktober" ) == 8 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "November" ) == 9 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "Dezember" ) == 9 ); - /* day name abbreviation */ - TESTCASE( j6libc_fprintf( fh, "%s\n", "So" ) == 3 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "Mo" ) == 3 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "Di" ) == 3 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "Mi" ) == 3 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "Do" ) == 3 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "Fr" ) == 3 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "Sa" ) == 3 ); - /* day name full */ - TESTCASE( j6libc_fprintf( fh, "%s\n", "Sonntag" ) == 8 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "Montag" ) == 7 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "Dienstag" ) == 9 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "Mittwoch" ) == 9 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "Donnerstag" ) == 11 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "Freitag" ) == 8 ); - TESTCASE( j6libc_fprintf( fh, "%s\n", "Samstag" ) == 8 ); - - TESTCASE( j6libc_fprintf( fh, "%s\n", "%a %d %b %Y %T %Z" ) == 18 ); /* date time format (%c) */ - TESTCASE( j6libc_fprintf( fh, "%s\n", "%I:%M:%S" ) == 9 ); /* 12-hour time format (%r) */ - TESTCASE( j6libc_fprintf( fh, "%s\n", "%d.%m.%Y" ) == 9 ); /* date format (%x) */ - TESTCASE( j6libc_fprintf( fh, "%s\n", "%H:%M:%S" ) == 9 ); /* time format (%X) */ - - TESTCASE( j6libc_fprintf( fh, "%s\n", "" ) == 1 ); /* AM */ - TESTCASE( j6libc_fprintf( fh, "%s\n", "" ) == 1 ); /* PM */ - fclose( fh ); - TESTCASE( ( lc = _PDCLIB_load_lc_time( "./", "test" ) ) ); - remove( "test_time.dat" ); - - TESTCASE( strcmp( lc->month_name_abbr[ 0 ], "Jan" ) == 0 ); - TESTCASE( strcmp( lc->month_name_abbr[ 11 ], "Dez" ) == 0 ); - TESTCASE( strcmp( lc->month_name_full[ 0 ], "Januar" ) == 0 ); - TESTCASE( strcmp( lc->month_name_full[ 11 ], "Dezember" ) == 0 ); - TESTCASE( strcmp( lc->day_name_abbr[ 0 ], "So" ) == 0 ); - TESTCASE( strcmp( lc->day_name_abbr[ 6 ], "Sa" ) == 0 ); - TESTCASE( strcmp( lc->day_name_full[ 0 ], "Sonntag" ) == 0 ); - TESTCASE( strcmp( lc->day_name_full[ 6 ], "Samstag" ) == 0 ); -} -END_TEST - -START_TEST( load_lines ) -{ - FILE * fh = fopen( "test_lines.txt", "w+" ); - char * rc; - - TESTCASE_REQUIRE( fh != NULL ); - TESTCASE( fputs( "Foo\n\nBar\n", fh ) != EOF ); - - rewind( fh ); - rc = _PDCLIB_load_lines( fh, 3 ); - fclose( fh ); - remove( "test_lines.txt" ); - - TESTCASE( rc != NULL ); - TESTCASE( strcmp( rc, "Foo" ) == 0 ); - TESTCASE( strcmp( rc + 4, "" ) == 0 ); - TESTCASE( strcmp( rc + 5, "Bar" ) == 0 ); -} -END_TEST - -static int testprintf( - const char *implfile, - const char *file, - int line, - size_t expected_rc, - const char *expected_out, - const char *format, - ... ) -{ - char buffer[100]; - - /* Members: base, flags, n, i, current, s, width, prec, stream, arg */ - struct _PDCLIB_status_t status; - status.base = 0; - status.flags = 0; - status.n = 100; - status.i = 0; - status.current = 0; - status.s = buffer; - status.width = 0; - status.prec = EOF; - status.stream = NULL; - - va_start( status.arg, format ); - memset( buffer, '\0', 100 ); - if ( *(_PDCLIB_print( format, &status )) != '\0' ) - { - fprintf( stderr, "_PDCLIB_print() did not return end-of-specifier on '%s'.\n", format ); - return 1; - } - va_end( status.arg ); - - if (status.i != expected_rc || - strcmp(buffer, expected_out)) - { - fprintf( stderr, - "FAILED: %s (%s), line %d\n" - " format string \"%s\"\n" - " expected %2lu, \"%s\"\n" - " actual %2lu, \"%s\"\n", - file, implfile, line, format, expected_rc, - expected_out, status.i, buffer ); - return 1; - } - - return 0; -} - -START_TEST( print ) -{ -#define IMPLFILE "_PDCLIB/print.c" -#define DO_TESTPRINTF testprintf -#define TEST_CONVERSION_ONLY -#include "printf_testcases.h" -#undef TEST_CONVERSION_ONLY -#undef DO_TESTPRINTF -#undef IMPLFILE -} -END_TEST - -static int testscanf( - const char *implfile, - const char *file, - int line, - size_t expected_rc, - const char *input_string, - const char *format, - ... ) -{ - char buffer[100]; - memcpy( buffer, input_string, strlen(input_string)+1 ); - - struct _PDCLIB_status_t status; - status.n = 0; - status.i = 0; - status.s = (char *)buffer; - status.stream = NULL; - - va_start( status.arg, format ); - if ( *(_PDCLIB_scan( format, &status )) != '\0' ) - { - fprintf( stderr, "_PDCLIB_scan() did not return end-of-specifier on '%s'.\n", format ); - return 1; - } - va_end( status.arg ); - - if ( status.n != expected_rc ) - { - fprintf( stderr, - "FAILED: %s (%s), line %d\n" - " expected %2lu,\n" - " actual %2lu\n", - file, implfile, line, expected_rc, status.n ); - return 1; - } - - return 0; -} - -START_TEST( scan ) -{ -#define IMPLFILE "_PDCLIB/scan.c" -#define DO_TESTSCANF testscanf -#define TEST_CONVERSION_ONLY -#include "scanf_testcases.h" -#undef TEST_CONVERSION_ONLY -#undef DO_TESTSCANF -#undef IMPLFILE -} -END_TEST - -START_TEST( strtox_main ) -{ - const char * p; - char test[] = "123_"; - char fail[] = "xxx"; - char sign = '-'; - errno = 0; - p = test; - - /* basic functionality */ - TESTCASE( - (_PDCLIB_strtox_main(&p, 10u, (uintmax_t)999, (uintmax_t)12, 3, &sign) == 123) && - (errno == 0) && - (p == &test[3]) ); - - /* proper functioning to smaller base */ - TESTCASE( - (_PDCLIB_strtox_main(&p, 8u, (uintmax_t)999, (uintmax_t)12, 3, &sign) == 0123) && - (errno == 0) && - (p == &test[3]) ); - - /* overflowing subject sequence must still return proper endptr */ - TESTCASE( - (_PDCLIB_strtox_main(&p, 4u, (uintmax_t)999, (uintmax_t)1, 2, &sign) == 999) && - (errno == ERANGE) && - (p == &test[3]) && - (sign == '+') ); - - /* testing conversion failure */ - p = fail; - sign = '-'; - TESTCASE( - (_PDCLIB_strtox_main(&p, 10u, (uintmax_t)999, (uintmax_t)99, 8, &sign) == 0) && - (p == NULL) ); -} -END_TEST - -START_TEST( strtox_prelim ) -{ - int base = 0; - char sign = '\0'; - char test1[] = " 123"; - char test2[] = "\t+0123"; - char test3[] = "\v-0x123"; - - TESTCASE( - (_PDCLIB_strtox_prelim(test1, &sign, &base) == &test1[2]) && - (sign == '+') && - (base == 10) ); - - TESTCASE( - (_PDCLIB_strtox_prelim(test2, &sign, &base) == &test2[3]) && - (sign == '+') && - (base == 8) ); - - TESTCASE( - (_PDCLIB_strtox_prelim(test3, &sign, &base) == &test3[4]) && - (sign == '-') && - (base == 16) ); - - base = 10; - TESTCASE( - (_PDCLIB_strtox_prelim(test3, &sign, &base) == &test3[2]) && - (sign == '-') && - (base == 10) ); - - base = 1; - TESTCASE( _PDCLIB_strtox_prelim(test3, &sign, &base) == NULL ); - - base = 37; - TESTCASE( _PDCLIB_strtox_prelim(test3, &sign, &base) == NULL ); -} -END_TEST - - - -START_SUITE( internal ) -{ - RUN_TEST( atomax ); - RUN_TEST( digits ); - RUN_TEST( filemode ); - RUN_TEST( is_leap ); - RUN_TEST( print ); - RUN_TEST( scan ); - RUN_TEST( strtox_main ); - RUN_TEST( strtox_prelim ); - - - // These fail due to lack of open() - /* - RUN_TEST( load_lc_ctype ); - RUN_TEST( load_lc_messages ); - RUN_TEST( load_lc_monetary ); - RUN_TEST( load_lc_numeric ); - RUN_TEST( load_lc_time ); - RUN_TEST( load_lines ); - */ -} -END_SUITE diff --git a/src/libraries/libc/tests/test_inttypes.c b/src/libraries/libc/tests/test_inttypes.c deleted file mode 100644 index 28e1798..0000000 --- a/src/libraries/libc/tests/test_inttypes.c +++ /dev/null @@ -1,194 +0,0 @@ -#include "_PDCLIB_test.h" - -START_TEST( imaxabs ) -{ - TESTCASE( imaxabs( (intmax_t)0 ) == 0 ); - TESTCASE( imaxabs( INTMAX_MAX ) == INTMAX_MAX ); - TESTCASE( imaxabs( INTMAX_MIN + 1 ) == -( INTMAX_MIN + 1 ) ); -} -END_TEST - -START_TEST( imaxdiv ) -{ - imaxdiv_t result; - result = imaxdiv( (intmax_t)5, (intmax_t)2 ); - TESTCASE( result.quot == 2 && result.rem == 1 ); - result = imaxdiv( (intmax_t)-5, (intmax_t)2 ); - TESTCASE( result.quot == -2 && result.rem == -1 ); - result = imaxdiv( (intmax_t)5, (intmax_t)-2 ); - TESTCASE( result.quot == -2 && result.rem == 1 ); - TESTCASE( sizeof( result.quot ) == sizeof( intmax_t ) ); - TESTCASE( sizeof( result.rem ) == sizeof( intmax_t ) ); -} -END_TEST - -START_TEST( strtoimax ) -{ - char * endptr; - /* this, to base 36, overflows even a 256 bit integer */ - char overflow[] = "-ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ_"; - /* tricky border case */ - char tricky[] = "+0xz"; - errno = 0; - - /* basic functionality */ - TESTCASE( strtoimax( "123", NULL, 10 ) == 123 ); - /* proper detecting of default base 10 */ - TESTCASE( strtoimax( "456", NULL, 0 ) == 456 ); - /* proper functioning to smaller base */ - TESTCASE( strtoimax( "14", NULL, 8 ) == 12 ); - /* proper autodetecting of octal */ - TESTCASE( strtoimax( "016", NULL, 0 ) == 14 ); - /* proper autodetecting of hexadecimal, lowercase 'x' */ - TESTCASE( strtoimax( "0xFF", NULL, 0 ) == 255 ); - /* proper autodetecting of hexadecimal, uppercase 'X' */ - TESTCASE( strtoimax( "0Xa1", NULL, 0 ) == 161 ); - - /* proper handling of border case: 0x followed by non-hexdigit */ - TESTCASE( - (strtoimax(tricky, &endptr, 0) == 0) && - (endptr == tricky + 2) && - (errno == 0) ); - - /* proper handling of border case: 0 followed by non-octdigit */ - TESTCASE( - (strtoimax(tricky, &endptr, 8) == 0) && - (endptr == tricky + 2) && - (errno == 0) ); - - /* overflowing subject sequence must still return proper endptr */ - TESTCASE( - (strtoimax(overflow, &endptr, 36) == INTMAX_MIN) && - (errno == ERANGE) && - ((endptr - overflow) == 53) ); - - /* same for positive */ - TESTCASE( - (strtoimax(overflow + 1, &endptr, 36) == INTMAX_MAX) && - (errno == ERANGE) && - ((endptr - overflow) == 53) ); - - /* testing skipping of leading whitespace */ - TESTCASE( strtoimax( " \n\v\t\f789", NULL, 0 ) == 789 ); - - /* testing conversion failure */ - TESTCASE( (strtoimax(overflow, &endptr, 10) == 0) && (endptr == overflow) ); - TESTCASE( (strtoimax(overflow, &endptr, 0) == 0) && (endptr == overflow) ); - /* These tests assume two-complement, but conversion should work for */ - /* one-complement and signed magnitude just as well. Anyone having a */ - /* platform to test this on? */ -#if INTMAX_MAX >> 62 == 1 - /* testing "odd" overflow, i.e. base is not a power of two */ - TESTCASE( (strtoimax("9223372036854775807", NULL, 0) == INTMAX_MAX) && (errno == 0) ); - TESTCASE( (strtoimax("9223372036854775808", NULL, 0) == INTMAX_MAX) && (errno == ERANGE) ); - TESTCASE( (strtoimax("-9223372036854775807", NULL, 0) == (INTMAX_MIN + 1)) && (errno == 0) ); - TESTCASE( (strtoimax("-9223372036854775808", NULL, 0) == INTMAX_MIN) && (errno == 0) ); - TESTCASE( (strtoimax("-9223372036854775809", NULL, 0) == INTMAX_MIN) && (errno == ERANGE) ); - /* testing "even" overflow, i.e. base is power of two */ - TESTCASE( (strtoimax("0x7fffffffffffffff", NULL, 0) == INTMAX_MAX) && (errno == 0) ); - TESTCASE( (strtoimax("0x8000000000000000", NULL, 0 ) == INTMAX_MAX) && (errno == ERANGE) ); - TESTCASE( (strtoimax("-0x7fffffffffffffff", NULL, 0 ) == (INTMAX_MIN + 1)) && (errno == 0) ); - TESTCASE( (strtoimax("-0x8000000000000000", NULL, 0 ) == INTMAX_MIN) && (errno == 0) ); - TESTCASE( (strtoimax("-0x8000000000000001", NULL, 0 ) == INTMAX_MIN) && (errno == ERANGE) ); -#elif LLONG_MAX >> 126 == 1 - /* testing "odd" overflow, i.e. base is not a power of two */ - TESTCASE( (strtoimax("170141183460469231731687303715884105728", NULL, 0 ) == INTMAX_MAX) && (errno == 0) ); - TESTCASE( (strtoimax("170141183460469231731687303715884105729", NULL, 0 ) == INTMAX_MAX) && (errno == ERANGE) ); - TESTCASE( (strtoimax("-170141183460469231731687303715884105728", NULL, 0 ) == (INTMAX_MIN + 1)) && (errno == 0) ); - TESTCASE( (strtoimax("-170141183460469231731687303715884105729", NULL, 0 ) == INTMAX_MIN) && (errno == 0) ); - TESTCASE( (strtoimax("-170141183460469231731687303715884105730", NULL, 0 ) == INTMAX_MIN) && (errno == ERANGE) ); - /* testing "even" overflow, i.e. base is power of two */ - TESTCASE( (strtoimax("0x7fffffffffffffffffffffffffffffff", NULL, 0 ) == INTMAX_MAX) && (errno == 0) ); - TESTCASE( (strtoimax("0x80000000000000000000000000000000", NULL, 0 ) == INTMAX_MAX) && (errno == ERANGE) ); - TESTCASE( (strtoimax("-0x7fffffffffffffffffffffffffffffff", NULL, 0 ) == (INTMAX_MIN + 1)) && (errno == 0) ); - TESTCASE( (strtoimax("-0x80000000000000000000000000000000", NULL, 0 ) == INTMAX_MIN) && (errno == 0) ); - TESTCASE( (strtoimax("-0x80000000000000000000000000000001", NULL, 0 ) == INTMAX_MIN) && (errno == ERANGE) ); -#else -#error Unsupported width of 'intmax_t' (neither 64 nor 128 bit). -#endif -} -END_TEST - -START_TEST( strtoumax ) -{ - char * endptr; - /* this, to base 36, overflows even a 256 bit integer */ - char overflow[] = "-ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ_"; - /* tricky border case */ - char tricky[] = "+0xz"; - errno = 0; - - /* basic functionality */ - TESTCASE( strtoumax( "123", NULL, 10 ) == 123 ); - /* proper detecting of default base 10 */ - TESTCASE( strtoumax( "456", NULL, 0 ) == 456 ); - /* proper functioning to smaller base */ - TESTCASE( strtoumax( "14", NULL, 8 ) == 12 ); - /* proper autodetecting of octal */ - TESTCASE( strtoumax( "016", NULL, 0 ) == 14 ); - /* proper autodetecting of hexadecimal, lowercase 'x' */ - TESTCASE( strtoumax( "0xFF", NULL, 0 ) == 255 ); - /* proper autodetecting of hexadecimal, uppercase 'X' */ - TESTCASE( strtoumax( "0Xa1", NULL, 0 ) == 161 ); - - /* proper handling of border case: 0x followed by non-hexdigit */ - TESTCASE( - (strtoumax(tricky, &endptr, 0) == 0) && - (endptr == tricky + 2) && - (errno == 0) ); - - /* proper handling of border case: 0 followed by non-octdigit */ - TESTCASE( - (strtoumax(tricky, &endptr, 8) == 0) && - (endptr == tricky + 2) && - (errno == 0) ); - - /* overflowing subject sequence must still return proper endptr */ - TESTCASE( - (strtoumax(overflow, &endptr, 36) == UINTMAX_MAX) && - (errno == ERANGE) && - ((endptr - overflow) == 53) ); - - /* same for positive */ - TESTCASE( - (strtoumax(overflow + 1, &endptr, 36) == UINTMAX_MAX) && - (errno == ERANGE) && - ((endptr - overflow) == 53) ); - - /* testing skipping of leading whitespace */ - TESTCASE( strtoumax( " \n\v\t\f789", NULL, 0 ) == 789 ); - - /* testing conversion failure */ - TESTCASE( (strtoumax(overflow, &endptr, 10) == 0) && (endptr == overflow) ); - TESTCASE( (strtoumax(overflow, &endptr, 0) == 0) && (endptr == overflow) ); -/* uintmax_t -> long long -> 64 bit */ -#if UINTMAX_MAX >> 63 == 1 - /* testing "odd" overflow, i.e. base is not power of two */ - TESTCASE( (strtoumax("18446744073709551615", NULL, 0) == UINTMAX_MAX) && (errno == 0) ); - TESTCASE( (strtoumax("18446744073709551616", NULL, 0) == UINTMAX_MAX) && (errno == ERANGE) ); - /* testing "even" overflow, i.e. base is power of two */ - TESTCASE( (strtoumax("0xFFFFFFFFFFFFFFFF", NULL, 0) == UINTMAX_MAX) && (errno == 0) ); - TESTCASE( (strtoumax("0x10000000000000000", NULL, 0) == UINTMAX_MAX) && (errno == ERANGE) ); -/* uintmax_t -> long long -> 128 bit */ -#elif UINTMAX_MAX >> 127 == 1 - /* testing "odd" overflow, i.e. base is not power of two */ - TESTCASE( (strtoumax("340282366920938463463374607431768211455", NULL, 0) == UINTMAX_MAX) && (errno == 0) ); - TESTCASE( (strtoumax("340282366920938463463374607431768211456", NULL, 0) == UINTMAX_MAX) && (errno == ERANGE) ); - /* testing "even" everflow, i.e. base is power of two */ - TESTCASE( (strtoumax("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", NULL, 0) == UINTMAX_MAX) && (errno == 0) ); - TESTCASE( (strtoumax("0x100000000000000000000000000000000", NULL, 0) == UINTMAX_MAX) && (errno == ERANGE) ); -#else -#error Unsupported width of 'uintmax_t' (neither 64 nor 128 bit). -#endif -} -END_TEST - - -START_SUITE( inttypes ) -{ - RUN_TEST( imaxabs ); - RUN_TEST( imaxdiv ); - RUN_TEST( strtoimax ); - RUN_TEST( strtoumax ); -} -END_SUITE diff --git a/src/libraries/libc/tests/test_locale.c b/src/libraries/libc/tests/test_locale.c deleted file mode 100644 index f7979b3..0000000 --- a/src/libraries/libc/tests/test_locale.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "_PDCLIB_test.h" - - -START_SUITE( locale ) -{ -} -END_SUITE diff --git a/src/libraries/libc/tests/test_signal.c b/src/libraries/libc/tests/test_signal.c deleted file mode 100644 index 88902c2..0000000 --- a/src/libraries/libc/tests/test_signal.c +++ /dev/null @@ -1,49 +0,0 @@ -#include "_PDCLIB_test.h" -#include - -static volatile sig_atomic_t flag = 0; - -static int expected_signal = 0; -static int received_signal = 0; - -static void test_handler( int sig ) -{ - flag = 1; -} - -START_TEST( raise ) -{ - /* Could be other than SIG_DFL if you changed the implementation. */ - TESTCASE( signal( SIGABRT, SIG_IGN ) == SIG_DFL ); - /* Should be ignored. */ - TESTCASE( raise( SIGABRT ) == 0 ); - /* Installing test handler, old handler should be returned */ - TESTCASE( signal( SIGABRT, test_handler ) == SIG_IGN ); - /* Raising and checking SIGABRT */ - expected_signal = SIGABRT; - TESTCASE( raise( SIGABRT ) == 0 ); - TESTCASE( flag == 1 ); - TESTCASE( received_signal == SIGABRT ); - /* Re-installing test handler, should have been reset to default */ - /* Could be other than SIG_DFL if you changed the implementation. */ - TESTCASE( signal( SIGABRT, test_handler ) == SIG_DFL ); - /* Raising and checking SIGABRT */ - flag = 0; - TESTCASE( raise( SIGABRT ) == 0 ); - TESTCASE( flag == 1 ); - TESTCASE( received_signal == SIGABRT ); - /* Installing test handler for different signal... */ - TESTCASE( signal( SIGTERM, test_handler ) == SIG_DFL ); - /* Raising and checking SIGTERM */ - expected_signal = SIGTERM; - TESTCASE( raise( SIGTERM ) == 0 ); - TESTCASE( flag == 1 ); - TESTCASE( received_signal == SIGTERM ); -} -END_TEST - -START_SUITE( signal ) -{ - RUN_TEST( raise ); -} -END_SUITE diff --git a/src/libraries/libc/tests/test_stdarg.c b/src/libraries/libc/tests/test_stdarg.c deleted file mode 100644 index 681af7d..0000000 --- a/src/libraries/libc/tests/test_stdarg.c +++ /dev/null @@ -1,67 +0,0 @@ -#include -#include -#include - -#include "_PDCLIB_test.h" - -typedef int (*intfunc_t)( void ); - -enum tag_t -{ - TAG_END, - TAG_INT, - TAG_LONG, - TAG_LLONG, - TAG_DBL, - TAG_LDBL, - TAG_INTPTR, - TAG_LDBLPTR, - TAG_FUNCPTR -}; - -static int dummy( void ) -{ - return INT_MAX; -} - -static int test( enum tag_t s, ... ) -{ - enum tag_t tag = s; - va_list ap; - va_start( ap, s ); - for (;;) - { - switch ( tag ) - { - case TAG_INT: if( va_arg( ap, int ) != INT_MAX ) return 0; break; - case TAG_LONG: if( va_arg( ap, long ) != LONG_MAX ) return 0; break; - case TAG_LLONG: if( va_arg( ap, long long ) != LLONG_MAX ) return 0; break; - case TAG_DBL: if( va_arg( ap, double ) != DBL_MAX ) return 0; break; - case TAG_LDBL: if( va_arg( ap, long double ) != LDBL_MAX ) return 0; break; - case TAG_INTPTR: if( *( va_arg( ap, int * ) ) != INT_MAX ) return 0; break; - case TAG_LDBLPTR: if( *( va_arg( ap, long double * ) ) != LDBL_MAX ) return 0; break; - case TAG_FUNCPTR: if( va_arg( ap, intfunc_t ) != dummy ) return 0; break; - case TAG_END: va_end( ap ); return 1; - } - tag = va_arg( ap, enum tag_t ); - } -} - -START_TEST( stdarg ) -{ - int x = INT_MAX; - long double d = LDBL_MAX; - TESTCASE( test(TAG_END) ); - TESTCASE( test(TAG_INT, INT_MAX, TAG_END) ); - TESTCASE( test(TAG_LONG, LONG_MAX, TAG_LLONG, LLONG_MAX, TAG_END) ); - TESTCASE( test(TAG_DBL, DBL_MAX, TAG_LDBL, LDBL_MAX, TAG_END) ); - TESTCASE( test(TAG_INTPTR, &x, TAG_LDBLPTR, &d, TAG_FUNCPTR, dummy, TAG_END) ); -} -END_TEST - - -START_SUITE( stdarg ) -{ - RUN_TEST( stdarg ); -} -END_SUITE diff --git a/src/libraries/libc/tests/test_stdio.c b/src/libraries/libc/tests/test_stdio.c deleted file mode 100644 index efe3388..0000000 --- a/src/libraries/libc/tests/test_stdio.c +++ /dev/null @@ -1,649 +0,0 @@ -#include "_PDCLIB_test.h" -#include "_PDCLIB_iotest.h" -#include - -extern struct _PDCLIB_file_t *_PDCLIB_filelist; - -START_TEST( clearerr ) -{ - FILE * fh = tmpfile(); - - TESTCASE_REQUIRE( fh != NULL ); - - /* Flags should be clear */ - TESTCASE( ! ferror( fh ) ); - TESTCASE( ! feof( fh ) ); - /* Reading from empty stream - should provoke EOF */ - rewind( fh ); - TESTCASE( fgetc( fh ) == EOF ); - TESTCASE( ! ferror( fh ) ); - TESTCASE( feof( fh ) ); - /* clearerr() should clear flags */ - clearerr( fh ); - TESTCASE( ! ferror( fh ) ); - TESTCASE( ! feof( fh ) ); - /* reopen() the file write-only */ - TESTCASE( ( fh = freopen( NULL, "w", fh ) ) != NULL ); - /* Reading from write-only stream - should provoke error */ - TESTCASE( fgetc( fh ) == EOF ); - TESTCASE( ferror( fh ) ); - TESTCASE( ! feof( fh ) ); - /* clearerr() should clear flags */ - clearerr( fh ); - TESTCASE( ! ferror( fh ) ); - TESTCASE( ! feof( fh ) ); - TESTCASE( fclose( fh ) == 0 ); -} -END_TEST - -START_TEST( fclose ) -{ - struct _PDCLIB_file_t * file1 = NULL; - struct _PDCLIB_file_t * file2 = NULL; - remove( testfile1 ); - remove( testfile2 ); - TESTCASE( _PDCLIB_filelist == stdin ); - TESTCASE( ( file1 = fopen( testfile1, "w" ) ) != NULL ); - TESTCASE( _PDCLIB_filelist == file1 ); - TESTCASE( ( file2 = fopen( testfile2, "w" ) ) != NULL ); - TESTCASE( _PDCLIB_filelist == file2 ); - TESTCASE( fclose( file2 ) == 0 ); - TESTCASE( _PDCLIB_filelist == file1 ); - TESTCASE( ( file2 = fopen( testfile2, "w" ) ) != NULL ); - TESTCASE( _PDCLIB_filelist == file2 ); - TESTCASE( fclose( file1 ) == 0 ); - TESTCASE( _PDCLIB_filelist == file2 ); - TESTCASE( fclose( file2 ) == 0 ); - TESTCASE( _PDCLIB_filelist == stdin ); - TESTCASE( remove( testfile1 ) == 0 ); - TESTCASE( remove( testfile2 ) == 0 ); -} -END_TEST - -START_TEST( fgetpos ) -{ - FILE * fh = tmpfile(); - fpos_t pos1, pos2; - TESTCASE_REQUIRE( fh != NULL ); - TESTCASE( fgetpos( fh, &pos1 ) == 0 ); - TESTCASE( fwrite( teststring, 1, strlen( teststring ), fh ) == strlen( teststring ) ); - TESTCASE( fgetpos( fh, &pos2 ) == 0 ); - TESTCASE( fsetpos( fh, &pos1 ) == 0 ); - TESTCASE( ftell( fh ) == 0 ); - TESTCASE( fsetpos( fh, &pos2 ) == 0 ); - TESTCASE( (size_t)ftell( fh ) == strlen( teststring ) ); - TESTCASE( fclose( fh ) == 0 ); -} -END_TEST - -START_TEST( fgets ) -{ - FILE * fh = NULL; - char buffer[10]; - const char * fgets_test = "foo\nbar\0baz\nweenie"; - TESTCASE_REQUIRE( ( fh = fopen( testfile, "wb+" ) ) != NULL ); - TESTCASE( fwrite( fgets_test, 1, 18, fh ) == 18 ); - rewind( fh ); - TESTCASE( fgets( buffer, 10, fh ) == buffer ); - TESTCASE( strcmp( buffer, "foo\n" ) == 0 ); - TESTCASE( fgets( buffer, 10, fh ) == buffer ); - TESTCASE( memcmp( buffer, "bar\0baz\n", 8 ) == 0 ); - TESTCASE( fgets( buffer, 10, fh ) == buffer ); - TESTCASE( strcmp( buffer, "weenie" ) == 0 ); - TESTCASE( feof( fh ) ); - TESTCASE( fseek( fh, -1, SEEK_END ) == 0 ); - TESTCASE( fgets( buffer, 1, fh ) == buffer ); - TESTCASE( strcmp( buffer, "" ) == 0 ); - TESTCASE( fgets( buffer, 0, fh ) == NULL ); - TESTCASE( ! feof( fh ) ); - TESTCASE( fgets( buffer, 1, fh ) == buffer ); - TESTCASE( strcmp( buffer, "" ) == 0 ); - TESTCASE( ! feof( fh ) ); - TESTCASE( fgets( buffer, 2, fh ) == buffer ); - TESTCASE( strcmp( buffer, "e" ) == 0 ); - TESTCASE( fseek( fh, 0, SEEK_END ) == 0 ); - TESTCASE( fgets( buffer, 2, fh ) == NULL ); - TESTCASE( feof( fh ) ); - TESTCASE( fclose( fh ) == 0 ); - TESTCASE( remove( testfile ) == 0 ); -} -END_TEST - -START_TEST( fopen ) -{ - /* Some of the tests are not executed for regression tests, as the libc on - my system is at once less forgiving (segfaults on mode NULL) and more - forgiving (accepts undefined modes). - */ - FILE * fh = NULL; - remove( testfile ); - TESTCASE( fopen( NULL, NULL ) == NULL ); - TESTCASE( fopen( NULL, "w" ) == NULL ); - TESTCASE( fopen( "", NULL ) == NULL ); - TESTCASE( fopen( "", "w" ) == NULL ); - TESTCASE( fopen( "foo", "" ) == NULL ); - TESTCASE( fopen( testfile, "wq" ) == NULL ); /* Undefined mode */ - TESTCASE( fopen( testfile, "wr" ) == NULL ); /* Undefined mode */ - TESTCASE( ( fh = fopen( testfile, "w" ) ) != NULL ); - TESTCASE( fclose( fh ) == 0 ); - TESTCASE( remove( testfile ) == 0 ); -} -END_TEST - -START_TEST( fputs ) -{ - const char * const message = "SUCCESS testing fputs()"; - FILE * fh = tmpfile(); - size_t i; - TESTCASE_REQUIRE( fh != NULL ); - TESTCASE( fputs( message, fh ) >= 0 ); - rewind( fh ); - for ( i = 0; i < 23; ++i ) - { - TESTCASE( fgetc( fh ) == message[i] ); - } - TESTCASE( fclose( fh ) == 0 ); -} -END_TEST - -START_TEST( fread ) -{ - FILE * fh = NULL; - const char * message = "Testing fwrite()...\n"; - char buffer[21]; - buffer[20] = 'x'; - TESTCASE_REQUIRE( ( fh = tmpfile() ) != NULL ); - /* fwrite() / readback */ - TESTCASE( fwrite( message, 1, 20, fh ) == 20 ); - rewind( fh ); - TESTCASE( fread( buffer, 1, 20, fh ) == 20 ); - TESTCASE( memcmp( buffer, message, 20 ) == 0 ); - TESTCASE( buffer[20] == 'x' ); - /* same, different nmemb / size settings */ - rewind( fh ); - TESTCASE( memset( buffer, '\0', 20 ) == buffer ); - TESTCASE( fwrite( message, 5, 4, fh ) == 4 ); - rewind( fh ); - TESTCASE( fread( buffer, 5, 4, fh ) == 4 ); - TESTCASE( memcmp( buffer, message, 20 ) == 0 ); - TESTCASE( buffer[20] == 'x' ); - /* same... */ - rewind( fh ); - TESTCASE( memset( buffer, '\0', 20 ) == buffer ); - TESTCASE( fwrite( message, 20, 1, fh ) == 1 ); - rewind( fh ); - TESTCASE( fread( buffer, 20, 1, fh ) == 1 ); - TESTCASE( memcmp( buffer, message, 20 ) == 0 ); - TESTCASE( buffer[20] == 'x' ); - /* Done. */ - TESTCASE( fclose( fh ) == 0 ); -} -END_TEST - -START_TEST( freopen ) -{ - FILE * fin = NULL; - FILE * fout = NULL; - TESTCASE_REQUIRE( ( fin = fopen( testfile1, "wb+" ) ) != NULL ); - TESTCASE( fputc( 'x', fin ) == 'x' ); - TESTCASE( fclose( fin ) == 0 ); - TESTCASE( ( fin = freopen( testfile1, "rb", stdin ) ) != NULL ); - TESTCASE( getchar() == 'x' ); - - TESTCASE( ( fout = freopen( testfile2, "wb+", stdout ) ) != NULL ); - TESTCASE( putchar( 'x' ) == 'x' ); - rewind( fout ); - TESTCASE( fgetc( fout ) == 'x' ); - - TESTCASE( fclose( fin ) == 0 ); - TESTCASE( fclose( fout ) == 0 ); - TESTCASE( remove( testfile1 ) == 0 ); - TESTCASE( remove( testfile2 ) == 0 ); -} -END_TEST - -START_TEST( fseek ) -{ - FILE * fh = NULL; - TESTCASE( ( fh = tmpfile() ) != NULL ); - TESTCASE( fwrite( teststring, 1, strlen( teststring ), fh ) == strlen( teststring ) ); - /* General functionality */ - TESTCASE( fseek( fh, -1, SEEK_END ) == 0 ); - TESTCASE( (size_t)ftell( fh ) == strlen( teststring ) - 1 ); - TESTCASE( fseek( fh, 0, SEEK_END ) == 0 ); - TESTCASE( (size_t)ftell( fh ) == strlen( teststring ) ); - TESTCASE( fseek( fh, 0, SEEK_SET ) == 0 ); - TESTCASE( ftell( fh ) == 0 ); - TESTCASE( fseek( fh, 5, SEEK_CUR ) == 0 ); - TESTCASE( ftell( fh ) == 5 ); - TESTCASE( fseek( fh, -3, SEEK_CUR ) == 0 ); - TESTCASE( ftell( fh ) == 2 ); - /* Checking behaviour around EOF */ - TESTCASE( fseek( fh, 0, SEEK_END ) == 0 ); - TESTCASE( ! feof( fh ) ); - TESTCASE( fgetc( fh ) == EOF ); - TESTCASE( feof( fh ) ); - TESTCASE( fseek( fh, 0, SEEK_END ) == 0 ); - TESTCASE( ! feof( fh ) ); - /* Checking undo of ungetc() */ - TESTCASE( fseek( fh, 0, SEEK_SET ) == 0 ); - TESTCASE( fgetc( fh ) == teststring[0] ); - TESTCASE( fgetc( fh ) == teststring[1] ); - TESTCASE( fgetc( fh ) == teststring[2] ); - TESTCASE( ftell( fh ) == 3 ); - TESTCASE( ungetc( teststring[2], fh ) == teststring[2] ); - TESTCASE( ftell( fh ) == 2 ); - TESTCASE( fgetc( fh ) == teststring[2] ); - TESTCASE( ftell( fh ) == 3 ); - TESTCASE( ungetc( 'x', fh ) == 'x' ); - TESTCASE( ftell( fh ) == 2 ); - TESTCASE( fgetc( fh ) == 'x' ); - TESTCASE( ungetc( 'x', fh ) == 'x' ); - TESTCASE( ftell( fh ) == 2 ); - TESTCASE( fseek( fh, 2, SEEK_SET ) == 0 ); - TESTCASE( fgetc( fh ) == teststring[2] ); - /* Checking error handling */ - TESTCASE( fseek( fh, -5, SEEK_SET ) == -1 ); - TESTCASE( fseek( fh, 0, SEEK_END ) == 0 ); - TESTCASE( fclose( fh ) == 0 ); -} -END_TEST - -START_TEST( ftell ) -{ - /* Testing all the basic I/O functions individually would result in lots - of duplicated code, so I took the liberty of lumping it all together - here. - */ - /* The following functions delegate their tests to here: - fgetc fflush rewind fputc ungetc fseek - flushbuffer seek fillbuffer prepread prepwrite - */ - char * buffer = (char*)malloc( 4 ); - FILE * fh = NULL; - TESTCASE_REQUIRE( ( fh = tmpfile() ) != NULL ); - TESTCASE( setvbuf( fh, buffer, _IOLBF, 4 ) == 0 ); - /* Testing ungetc() at offset 0 */ - rewind( fh ); - TESTCASE( ungetc( 'x', fh ) == 'x' ); - TESTCASE( ftell( fh ) == -1l ); - rewind( fh ); - TESTCASE( ftell( fh ) == 0l ); - /* Commence "normal" tests */ - TESTCASE( fputc( '1', fh ) == '1' ); - TESTCASE( fputc( '2', fh ) == '2' ); - TESTCASE( fputc( '3', fh ) == '3' ); - /* Positions incrementing as expected? */ - TESTCASE( ftell( fh ) == 3l ); - TESTCASE( fh->pos.offset == 0l ); - TESTCASE( fh->bufidx == 3l ); - /* Buffer properly flushed when full? */ - TESTCASE( fputc( '4', fh ) == '4' ); - TESTCASE( fh->pos.offset == 4l ); - TESTCASE( fh->bufidx == 0 ); - /* fflush() resetting positions as expected? */ - TESTCASE( fputc( '5', fh ) == '5' ); - TESTCASE( fflush( fh ) == 0 ); - TESTCASE( ftell( fh ) == 5l ); - TESTCASE( fh->pos.offset == 5l ); - TESTCASE( fh->bufidx == 0l ); - /* rewind() resetting positions as expected? */ - rewind( fh ); - TESTCASE( ftell( fh ) == 0l ); - TESTCASE( fh->pos.offset == 0 ); - TESTCASE( fh->bufidx == 0 ); - /* Reading back first character after rewind for basic read check */ - TESTCASE( fgetc( fh ) == '1' ); - /* TODO: t.b.c. */ - TESTCASE( fclose( fh ) == 0 ); -} -END_TEST - -START_TEST( perror ) -{ - FILE * fh = NULL; - unsigned long long max = ULLONG_MAX; - char buffer[100]; - sprintf( buffer, "%llu", max ); - TESTCASE_REQUIRE( ( fh = freopen( testfile, "wb+", j6libc_stderr ) ) != NULL ); - TESTCASE( strtol( buffer, NULL, 10 ) == LONG_MAX ); - perror( "Test" ); - rewind( fh ); - TESTCASE( fread( buffer, 1, 7, fh ) == 7 ); - TESTCASE( memcmp( buffer, "Test: ", 6 ) == 0 ); - TESTCASE( fclose( fh ) == 0 ); - TESTCASE( remove( testfile ) == 0 ); -} -END_TEST - -START_TEST( puts ) -{ - FILE * fh = NULL; - const char * message = "SUCCESS testing puts()"; - char buffer[23]; - buffer[22] = 'x'; - TESTCASE_REQUIRE( ( fh = freopen( testfile, "wb+", stdout ) ) != NULL ); - TESTCASE( puts( message ) >= 0 ); - rewind( fh ); - TESTCASE( fread( buffer, 1, 22, fh ) == 22 ); - TESTCASE( memcmp( buffer, message, 22 ) == 0 ); - TESTCASE( buffer[22] == 'x' ); - TESTCASE( fclose( fh ) == 0 ); - TESTCASE( remove( testfile ) == 0 ); -} -END_TEST - -START_TEST( rename ) -{ - FILE * file = NULL; - remove( testfile1 ); - remove( testfile2 ); - /* make sure that neither file exists */ - TESTCASE( fopen( testfile1, "r" ) == NULL ); - TESTCASE( fopen( testfile2, "r" ) == NULL ); - /* rename file 1 to file 2 - expected to fail */ - TESTCASE( rename( testfile1, testfile2 ) == -1 ); - /* create file 1 */ - TESTCASE_REQUIRE( ( file = fopen( testfile1, "w" ) ) != NULL ); - TESTCASE( fputs( "x", file ) != EOF ); - TESTCASE( fclose( file ) == 0 ); - /* check that file 1 exists */ - TESTCASE( ( file = fopen( testfile1, "r" ) ) != NULL ); - TESTCASE( fclose( file ) == 0 ); - /* rename file 1 to file 2 */ - TESTCASE( rename( testfile1, testfile2 ) == 0 ); - /* check that file 2 exists, file 1 does not */ - TESTCASE( fopen( testfile1, "r" ) == NULL ); - TESTCASE( ( file = fopen( testfile2, "r" ) ) != NULL ); - TESTCASE( fclose( file ) == 0 ); - /* create another file 1 */ - TESTCASE( ( file = fopen( testfile1, "w" ) ) != NULL ); - TESTCASE( fputs( "x", file ) != EOF ); - TESTCASE( fclose( file ) == 0 ); - /* check that file 1 exists */ - TESTCASE( ( file = fopen( testfile1, "r" ) ) != NULL ); - TESTCASE( fclose( file ) == 0 ); - /* rename file 1 to file 2 - expected to fail, see comment in - _PDCLIB_rename() itself. - */ - /* NOREG as glibc overwrites existing destination file. */ - TESTCASE( rename( testfile1, testfile2 ) == -1 ); - /* remove both files */ - TESTCASE( remove( testfile1 ) == 0 ); - TESTCASE( remove( testfile2 ) == 0 ); - /* check that they're gone */ - TESTCASE( fopen( testfile1, "r" ) == NULL ); - TESTCASE( fopen( testfile2, "r" ) == NULL ); -} -END_TEST - -START_TEST( setbuf ) -{ - /* TODO: Extend testing once setvbuf() is finished. */ - char buffer[ BUFSIZ + 1 ]; - FILE * fh = NULL; - /* full buffered */ - TESTCASE_REQUIRE( ( fh = tmpfile() ) != NULL ); - setbuf( fh, buffer ); - TESTCASE( fh->buffer == buffer ); - TESTCASE( fh->bufsize == BUFSIZ ); - TESTCASE( ( fh->status & ( _IOFBF | _IONBF | _IOLBF ) ) == _IOFBF ); - TESTCASE( fclose( fh ) == 0 ); - /* not buffered */ - TESTCASE( ( fh = tmpfile() ) != NULL ); - setbuf( fh, NULL ); - TESTCASE( ( fh->status & ( _IOFBF | _IONBF | _IOLBF ) ) == _IONBF ); - TESTCASE( fclose( fh ) == 0 ); -} -END_TEST - - -START_TEST( setvbuf ) -{ -#define BUFFERSIZE 500 - char buffer[ BUFFERSIZE ]; - FILE * fh = NULL; - /* full buffered, user-supplied buffer */ - TESTCASE_REQUIRE( ( fh = tmpfile() ) != NULL ); - TESTCASE( setvbuf( fh, buffer, _IOFBF, BUFFERSIZE ) == 0 ); - TESTCASE( fh->buffer == buffer ); - TESTCASE( fh->bufsize == BUFFERSIZE ); - TESTCASE( ( fh->status & ( _IOFBF | _IONBF | _IOLBF ) ) == _IOFBF ); - TESTCASE( fclose( fh ) == 0 ); - /* line buffered, lib-supplied buffer */ - TESTCASE( ( fh = tmpfile() ) != NULL ); - TESTCASE( setvbuf( fh, NULL, _IOLBF, BUFFERSIZE ) == 0 ); - TESTCASE( fh->buffer != NULL ); - TESTCASE( fh->bufsize == BUFFERSIZE ); - TESTCASE( ( fh->status & ( _IOFBF | _IONBF | _IOLBF ) ) == _IOLBF ); - TESTCASE( fclose( fh ) == 0 ); - /* not buffered, user-supplied buffer */ - TESTCASE( ( fh = tmpfile() ) != NULL ); - TESTCASE( setvbuf( fh, buffer, _IONBF, BUFFERSIZE ) == 0 ); - TESTCASE( ( fh->status & ( _IOFBF | _IONBF | _IOLBF ) ) == _IONBF ); - TESTCASE( fclose( fh ) == 0 ); -#undef BUFFERSIZE -} -END_TEST - -START_TEST( tmpnam ) -{ - TESTCASE( strlen( tmpnam( NULL ) ) < L_tmpnam ); -} -END_TEST - - -FILE * test_vfprintf_stream = NULL; - -static int test_vfprintf( - const char *implfile, - const char *file, - int line, - size_t expected_rc, - const char *expected_out, - const char *format, - ... ) -{ - size_t i; - va_list arg; - va_start( arg, format ); - i = vfprintf( test_vfprintf_stream, format, arg ); - va_end( arg ); - - char result_buffer[100]; - rewind(test_vfprintf_stream); - if ( fread( result_buffer, 1, i, test_vfprintf_stream ) != i ) - { - fprintf( stderr, - "FAILED: %s (%s), line %d\n" - " GET RESULT FAILURE", - file, implfile, line); - return 1; - } - - if (i != expected_rc || - strcmp(result_buffer, expected_out)) - { - fprintf( stderr, - "FAILED: %s (%s), line %d\n" - " format string \"%s\"\n" - " expected %2lu, \"%s\"\n" - " actual %2lu, \"%s\"\n", - file, implfile, line, format, expected_rc, - expected_out, i, result_buffer ); - return 1; - } - - return 0; -} - -START_TEST( vfprintf ) -{ - TESTCASE_REQUIRE( ( test_vfprintf_stream = tmpfile() ) != NULL ); -#define IMPLFILE "stdio/vfprintf.c" -#define DO_TESTPRINTF test_vfprintf -#include "printf_testcases.h" -#undef DO_TESTPRINTF -#undef IMPLFILE - TESTCASE( fclose( test_vfprintf_stream ) == 0 ); -} -END_TEST - -FILE * test_vfscanf_stream = NULL; - -static int test_vfscanf( - const char *implfile, - const char *file, - int line, - size_t expected_rc, - const char *input_string, - const char *format, - ... ) -{ - rewind( test_vfscanf_stream ); - fwrite( input_string, 1, strlen(input_string)+1, test_vfscanf_stream ); - rewind( test_vfscanf_stream ); - - va_list ap; - size_t result; - va_start( ap, format ); - result = vfscanf( test_vfscanf_stream, format, ap ); - va_end( ap ); - - if (result != expected_rc ) - { - fprintf( stderr, - "FAILED: %s (%s), line %d\n" - " format string \"%s\"\n" - " expected %2lu\n" - " actual %2lu\n", - file, implfile, line, format, - expected_rc, result); - return 1; - } - - return 0; -} - -START_TEST( vfscanf ) -{ - TESTCASE_REQUIRE( ( test_vfscanf_stream = tmpfile() ) != NULL ); -#define IMPLFILE "stdio/vfscanf.c" -#define DO_TESTSCANF test_vfscanf -#include "scanf_testcases.h" -#undef DO_TESTSCANF -#undef IMPLFILE - TESTCASE( fclose( test_vfprintf_stream ) == 0 ); -} -END_TEST - -static int test_vsnprintf( - const char *implfile, - const char *file, - int line, - size_t expected_rc, - const char *expected_out, - const char *format, - ... ) -{ - char buffer[100]; - size_t i; - va_list arg; - va_start( arg, format ); - i = vsnprintf( buffer, 100, format, arg ); - va_end( arg ); - - if (i != expected_rc || - strcmp(buffer, expected_out)) - { - fprintf( stderr, - "FAILED: %s (%s), line %d\n" - " format string \"%s\"\n" - " expected %2lu, \"%s\"\n" - " actual %2lu, \"%s\"\n", - file, implfile, line, format, expected_rc, - expected_out, i, buffer ); - return 1; - } - - return 0; -} - -START_TEST( vsnprintf ) -{ -#define IMPLFILE "stdio/vsnprintf.c" -#define DO_TESTPRINTF test_vsnprintf -#include "printf_testcases.h" -#undef DO_TESTPRINTF -#undef IMPLFILE -} -END_TEST - -static int test_vsscanf( - const char *implfile, - const char *file, - int line, - size_t expected_rc, - const char *input_string, - const char *format, - ... ) -{ - va_list ap; - size_t result; - va_start( ap, format ); - result = vsscanf( input_string, format, ap ); - va_end( ap ); - - if (result != expected_rc ) - { - fprintf( stderr, - "FAILED: %s (%s), line %d\n" - " format string \"%s\"\n" - " expected %2lu\n" - " actual %2lu\n", - file, implfile, line, format, - expected_rc, result); - return 1; - } - - return 0; -} - -START_TEST( vsscanf ) -{ -#define IMPLFILE "stdio/vsscanf.c" -#define DO_TESTSCANF test_vsscanf -#include "scanf_testcases.h" -#undef DO_TESTSCANF -#undef IMPLFILE -} -END_TEST - - -START_SUITE( stdio ) -{ - /* TODO: File IO not yet implemented - RUN_TEST( clearerr ); - RUN_TEST( fclose ); - RUN_TEST( fgetpos ); - RUN_TEST( fgets ); - RUN_TEST( fopen ); - RUN_TEST( fputs ); - RUN_TEST( fread ); - RUN_TEST( freopen ); - RUN_TEST( fseek ); - RUN_TEST( ftell ); - RUN_TEST( perror ); - RUN_TEST( puts ); - RUN_TEST( rename ); - RUN_TEST( setbuf ); - RUN_TEST( setvbuf ); - RUN_TEST( vfprintf ); - RUN_TEST( vfscanf ); - */ - - RUN_TEST( tmpnam ); - RUN_TEST( vsnprintf ); - RUN_TEST( vsscanf ); -} -END_SUITE diff --git a/src/libraries/libc/tests/test_stdlib.c b/src/libraries/libc/tests/test_stdlib.c deleted file mode 100644 index 87e3616..0000000 --- a/src/libraries/libc/tests/test_stdlib.c +++ /dev/null @@ -1,515 +0,0 @@ -#include "_PDCLIB_test.h" -#include - - -static int test_exit() { _Exit(0); return 0; } - -START_TEST( _Exit ) -{ - TESTCASE( test_exit() ); -} -END_TEST - -static void aborthandler(int s) { _exit(0); } -static int test_abort() { abort(); return 0; } - -START_TEST( abort ) -{ - TESTCASE( signal( SIGABRT, &aborthandler ) != SIG_ERR ); - TESTCASE( test_abort() ); -} -END_TEST - -START_TEST( abs ) -{ - TESTCASE( abs( 0 ) == 0 ); - TESTCASE( abs( INT_MAX ) == INT_MAX ); - TESTCASE( abs( INT_MIN + 1 ) == -( INT_MIN + 1 ) ); -} -END_TEST - -static int flags[ 32 ]; - -static void counthandler( void ) -{ - static int count = 0; - flags[ count ] = count; - ++count; -} - -static void checkhandler( void ) -{ - for ( int i = 0; i < 31; ++i ) - assert( flags[ i ] == i ); -} - -int test_atexit() -{ - if( atexit( &checkhandler ) != 0 ) - return 0; - - for ( int i = 0; i < 31; ++i ) - if( atexit( &counthandler ) != 0 ) - return 0; - - return 1; -} - -START_TEST( atexit ) -{ - TESTCASE( test_atexit() ); -} -END_TEST - -static int compare( const void * left, const void * right ) -{ - return *( (unsigned char *)left ) - *( (unsigned char *)right ); -} - -START_TEST( bsearch ) -{ - TESTCASE( bsearch( "e", abcde, 4, 1, compare ) == NULL ); - TESTCASE( bsearch( "e", abcde, 5, 1, compare ) == &abcde[4] ); - TESTCASE( bsearch( "a", abcde + 1, 4, 1, compare ) == NULL ); - TESTCASE( bsearch( "0", abcde, 1, 1, compare ) == NULL ); - TESTCASE( bsearch( "a", abcde, 1, 1, compare ) == &abcde[0] ); - TESTCASE( bsearch( "a", abcde, 0, 1, compare ) == NULL ); - TESTCASE( bsearch( "e", abcde, 3, 2, compare ) == &abcde[4] ); - TESTCASE( bsearch( "b", abcde, 3, 2, compare ) == NULL ); -} -END_TEST - -START_TEST( div ) -{ - div_t result = div( 5, 2 ); - TESTCASE( result.quot == 2 && result.rem == 1 ); - result = div( -5, 2 ); - TESTCASE( result.quot == -2 && result.rem == -1 ); - result = div( 5, -2 ); - TESTCASE( result.quot == -2 && result.rem == 1 ); - TESTCASE( sizeof( result.quot ) == sizeof( int ) ); - TESTCASE( sizeof( result.rem ) == sizeof( int ) ); -} -END_TEST - -START_TEST( getenv ) -{ - TESTCASE( strcmp( getenv( "SHELL" ), "/bin/bash" ) == 0 ); -} -END_TEST - -START_TEST( labs ) -{ - TESTCASE( labs( 0 ) == 0 ); - TESTCASE( labs( LONG_MAX ) == LONG_MAX ); - TESTCASE( labs( LONG_MIN + 1 ) == -( LONG_MIN + 1 ) ); -} -END_TEST - -START_TEST( ldiv ) -{ - ldiv_t result = ldiv( 5, 2 ); - TESTCASE( result.quot == 2 && result.rem == 1 ); - result = ldiv( -5, 2 ); - TESTCASE( result.quot == -2 && result.rem == -1 ); - result = ldiv( 5, -2 ); - TESTCASE( result.quot == -2 && result.rem == 1 ); - TESTCASE( sizeof( result.quot ) == sizeof( long ) ); - TESTCASE( sizeof( result.rem ) == sizeof( long ) ); -} -END_TEST - -START_TEST( llabs ) -{ - TESTCASE( llabs( 0ll ) == 0 ); - TESTCASE( llabs( LLONG_MAX ) == LLONG_MAX ); - TESTCASE( llabs( LLONG_MIN + 1 ) == -( LLONG_MIN + 1 ) ); -} -END_TEST - -START_TEST( lldiv ) -{ - lldiv_t result = lldiv( 5ll, 2ll ); - TESTCASE( result.quot == 2 && result.rem == 1 ); - result = lldiv( -5ll, 2ll ); - TESTCASE( result.quot == -2 && result.rem == -1 ); - result = lldiv( 5ll, -2ll ); - TESTCASE( result.quot == -2 && result.rem == 1 ); - TESTCASE( sizeof( result.quot ) == sizeof( long long ) ); - TESTCASE( sizeof( result.rem ) == sizeof( long long ) ); -} -END_TEST - -START_TEST( qsort ) -{ - char presort[] = { "shreicnyjqpvozxmbt" }; - char sorted1[] = { "bcehijmnopqrstvxyz" }; - char sorted2[] = { "bticjqnyozpvreshxm" }; - char s[19]; - strcpy( s, presort ); - qsort( s, 18, 1, compare ); - TESTCASE( strcmp( s, sorted1 ) == 0 ); - strcpy( s, presort ); - qsort( s, 9, 2, compare ); - TESTCASE( strcmp( s, sorted2 ) == 0 ); - strcpy( s, presort ); - qsort( s, 1, 1, compare ); - TESTCASE( strcmp( s, presort ) == 0 ); - qsort( s, 100, 0, compare ); - TESTCASE( strcmp( s, presort ) == 0 ); -} -END_TEST - -START_TEST( rand ) -{ - int rnd1 = RAND_MAX, rnd2 = RAND_MAX; - TESTCASE( ( rnd1 = rand() ) < RAND_MAX ); - TESTCASE( ( rnd2 = rand() ) < RAND_MAX ); - srand( 1 ); - TESTCASE( rand() == rnd1 ); - TESTCASE( rand() == rnd2 ); -} -END_TEST - -START_TEST( strtol ) -{ - char * endptr = NULL; - /* this, to base 36, overflows even a 256 bit integer */ - char overflow[] = "-ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ_"; - /* tricky border case */ - char tricky[] = "+0xz"; - errno = 0; - - /* basic functionality */ - TESTCASE( strtol( "123", NULL, 10 ) == 123 ); - /* proper detecting of default base 10 */ - TESTCASE( strtol( "456", NULL, 0 ) == 456 ); - /* proper functioning to smaller base */ - TESTCASE( strtol( "14", NULL, 8 ) == 12 ); - /* proper autodetecting of octal */ - TESTCASE( strtol( "016", NULL, 0 ) == 14 ); - /* proper autodetecting of hexadecimal, lowercase 'x' */ - TESTCASE( strtol( "0xFF", NULL, 0 ) == 255 ); - /* proper autodetecting of hexadecimal, uppercase 'X' */ - TESTCASE( strtol( "0Xa1", NULL, 0 ) == 161 ); - - /* proper handling of border case: 0x followed by non-hexdigit */ - TESTCASE( - (strtol(tricky, &endptr, 0) == 0) && - (endptr == tricky + 2) && - (errno == 0) ); - - /* proper handling of border case: 0 followed by non-octdigit */ - TESTCASE( - (strtol(tricky, &endptr, 8) == 0) && - (endptr == tricky + 2) && - (errno == 0) ); - - /* overflowing subject sequence must still return proper endptr */ - TESTCASE( - (strtol(overflow, &endptr, 36) == LONG_MIN) && - (errno == ERANGE) && - ((endptr - overflow) == 53) ); - - /* same for positive */ - TESTCASE( - (strtol(overflow + 1, &endptr, 36) == LONG_MAX) && - (errno == ERANGE) && - ((endptr - overflow) == 53) ); - - /* testing skipping of leading whitespace */ - TESTCASE( strtol( " \n\v\t\f789", NULL, 0 ) == 789 ); - - /* testing conversion failure */ - TESTCASE( - (strtol(overflow, &endptr, 10) == 0) && - (endptr == overflow) ); - - TESTCASE( - (strtol(overflow, &endptr, 0) == 0) && - (endptr == overflow) ); - -#if __SIZEOF_LONG__ == 4 - /* testing "even" overflow, i.e. base is power of two */ - TESTCASE( (strtol("2147483647", NULL, 0) == 0x7fffffff) && (errno == 0) ); - TESTCASE( (strtol("2147483648", NULL, 0) == LONG_MAX) && (errno == ERANGE) ); - TESTCASE( (strtol("-2147483647", NULL, 0) == (long)0x80000001) && (errno == 0) ); - TESTCASE( (strtol("-2147483648", NULL, 0) == LONG_MIN) && (errno == 0) ); - TESTCASE( (strtol("-2147483649", NULL, 0) == LONG_MIN) && (errno == ERANGE) ); - /* TODO: test "odd" overflow, i.e. base is not power of two */ -#elif __SIZEOF_LONG__ == 8 - /* testing "even" overflow, i.e. base is power of two */ - TESTCASE( (strtol("9223372036854775807", NULL, 0) == 0x7fffffffffffffff) && (errno == 0) ); - TESTCASE( (strtol("9223372036854775808", NULL, 0) == LONG_MAX) && (errno == ERANGE) ); - TESTCASE( (strtol("-9223372036854775807", NULL, 0) == (long)0x8000000000000001) && (errno == 0) ); - TESTCASE( (strtol("-9223372036854775808", NULL, 0) == LONG_MIN) && (errno == 0) ); - TESTCASE( (strtol("-9223372036854775809", NULL, 0) == LONG_MIN) && (errno == ERANGE) ); - /* TODO: test "odd" overflow, i.e. base is not power of two */ -#else -#error Unsupported width of 'long' (neither 32 nor 64 bit). -#endif -} -END_TEST - -START_TEST( strtoll ) -{ - char * endptr = NULL; - /* this, to base 36, overflows even a 256 bit integer */ - char overflow[] = "-ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ_"; - /* tricky border case */ - char tricky[] = "+0xz"; - errno = 0; - - /* basic functionality */ - TESTCASE( strtoll( "123", NULL, 10 ) == 123 ); - /* proper detecting of default base 10 */ - TESTCASE( strtoll( "456", NULL, 0 ) == 456 ); - /* proper functioning to smaller base */ - TESTCASE( strtoll( "14", NULL, 8 ) == 12 ); - /* proper autodetecting of octal */ - TESTCASE( strtoll( "016", NULL, 0 ) == 14 ); - /* proper autodetecting of hexadecimal, lowercase 'x' */ - TESTCASE( strtoll( "0xFF", NULL, 0 ) == 255 ); - /* proper autodetecting of hexadecimal, uppercase 'X' */ - TESTCASE( strtoll( "0Xa1", NULL, 0 ) == 161 ); - - /* proper handling of border case: 0x followed by non-hexdigit */ - TESTCASE( - (strtoll(tricky, &endptr, 0) == 0) && - (endptr == tricky + 2) && - (errno == 0) ); - - /* proper handling of border case: 0 followed by non-octdigit */ - TESTCASE( - (strtoll(tricky, &endptr, 8) == 0) && - (endptr == tricky + 2) && - (errno == 0) ); - - /* overflowing subject sequence must still return proper endptr */ - TESTCASE( - (strtoll(overflow, &endptr, 36) == LLONG_MIN) && - (errno == ERANGE) && - ((endptr - overflow) == 53) ); - - /* same for positive */ - TESTCASE( - (strtoll(overflow + 1, &endptr, 36) == LLONG_MAX) && - (errno == ERANGE) && - ((endptr - overflow) == 53) ); - - /* testing skipping of leading whitespace */ - TESTCASE( strtoll( " \n\v\t\f789", NULL, 0 ) == 789 ); - - /* testing conversion failure */ - TESTCASE( (strtoll(overflow, &endptr, 10) == 0) && (endptr == overflow) ); - TESTCASE( (strtoll(overflow, &endptr, 0) == 0) && (endptr == overflow) ); - - /* TODO: These tests assume two-complement, but conversion should work */ - /* for one-complement and signed magnitude just as well. Anyone having */ - /* a platform to test this on? */ -#if __SIZEOF_LONG_LONG__ == 8 - /* testing "even" overflow, i.e. base is power of two */ - TESTCASE( (strtoll("9223372036854775807", NULL, 0) == 0x7fffffffffffffff) && (errno == 0) ); - TESTCASE( (strtoll("9223372036854775808", NULL, 0) == LLONG_MAX) && (errno == ERANGE) ); - TESTCASE( (strtoll("-9223372036854775807", NULL, 0) == (long long)0x8000000000000001) && (errno == 0) ); - TESTCASE( (strtoll("-9223372036854775808", NULL, 0) == LLONG_MIN) && (errno == 0) ); - TESTCASE( (strtoll("-9223372036854775809", NULL, 0) == LLONG_MIN) && (errno == ERANGE) ); - /* TODO: test "odd" overflow, i.e. base is not power of two */ -#elif __SIZEOF_LONG_LONG__ == 16 - /* testing "even" overflow, i.e. base is power of two */ - TESTCASE( (strtoll("170141183460469231731687303715884105728", NULL, 0) == 0x7fffffffffffffffffffffffffffffff) && (errno == 0) ); - TESTCASE( (strtoll("170141183460469231731687303715884105729", NULL, 0) == LLONG_MAX) && (errno == ERANGE) ); - TESTCASE( (strtoll("-170141183460469231731687303715884105728", NULL, 0) == -0x80000000000000000000000000000001) && (errno == 0) ); - TESTCASE( (strtoll("-170141183460469231731687303715884105729", NULL, 0) == LLONG_MIN) && (errno == 0) ); - TESTCASE( (strtoll("-170141183460469231731687303715884105730", NULL, 0) == LLONG_MIN) && (errno == ERANGE) ); - /* TODO: test "odd" overflow, i.e. base is not power of two */ -#else -#error Unsupported width of 'long long' (neither 64 nor 128 bit). -#endif -} -END_TEST - -START_TEST( strtoul ) -{ - char * endptr = NULL; - /* this, to base 36, overflows even a 256 bit integer */ - char overflow[] = "-ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ_"; - /* tricky border case */ - char tricky[] = "+0xz"; - errno = 0; - /* basic functionality */ - TESTCASE( strtoul( "123", NULL, 10 ) == 123 ); - /* proper detecting of default base 10 */ - TESTCASE( strtoul( "456", NULL, 0 ) == 456 ); - /* proper functioning to smaller base */ - TESTCASE( strtoul( "14", NULL, 8 ) == 12 ); - /* proper autodetecting of octal */ - TESTCASE( strtoul( "016", NULL, 0 ) == 14 ); - /* proper autodetecting of hexadecimal, lowercase 'x' */ - TESTCASE( strtoul( "0xFF", NULL, 0 ) == 255 ); - /* proper autodetecting of hexadecimal, uppercase 'X' */ - TESTCASE( strtoul( "0Xa1", NULL, 0 ) == 161 ); - - /* proper handling of border case: 0x followed by non-hexdigit */ - TESTCASE( - (strtoul(tricky, &endptr, 0) == 0) && - (endptr == tricky + 2) && - (errno == 0) ); - - /* proper handling of border case: 0 followed by non-octdigit */ - TESTCASE( - (strtoul(tricky, &endptr, 8) == 0) && - (endptr == tricky + 2) && - (errno == 0) ); - - /* overflowing subject sequence must still return proper endptr */ - TESTCASE( - (strtoul(overflow, &endptr, 36) == ULONG_MAX) && - (errno == ERANGE) && - ((endptr - overflow) == 53) ); - - /* same for positive */ - TESTCASE( - (strtoul(overflow + 1, &endptr, 36) == ULONG_MAX) && - (errno == ERANGE) && - ((endptr - overflow) == 53) ); - - /* testing skipping of leading whitespace */ - TESTCASE( strtoul( " \n\v\t\f789", NULL, 0 ) == 789 ); - - /* testing conversion failure */ - TESTCASE( (strtoul(overflow, &endptr, 10) == 0) && (endptr == overflow) ); - TESTCASE( (strtoul(overflow, &endptr, 0) == 0) && (endptr == overflow) ); - - /* TODO: These tests assume two-complement, but conversion should work */ - /* for one-complement and signed magnitude just as well. Anyone having */ - /* a platform to test this on? */ -/* long -> 32 bit */ -#if __SIZEOF_LONG__ == 4 - /* testing "even" overflow, i.e. base is power of two */ - TESTCASE( (strtoul("4294967295", NULL, 0) == ULONG_MAX) && (errno == 0) ); - TESTCASE( (strtoul("4294967296", NULL, 0) == ULONG_MAX) && (errno == ERANGE) ); - /* TODO: test "odd" overflow, i.e. base is not power of two */ -/* long -> 64 bit */ -#elif __SIZEOF_LONG__ == 8 - /* testing "even" overflow, i.e. base is power of two */ - TESTCASE( (strtoul("18446744073709551615", NULL, 0) == ULONG_MAX) && (errno == 0) ); - TESTCASE( (strtoul("18446744073709551616", NULL, 0) == ULONG_MAX) && (errno == ERANGE) ); - /* TODO: test "odd" overflow, i.e. base is not power of two */ -#else -#error Unsupported width of 'long' (neither 32 nor 64 bit). -#endif -} -END_TEST - -START_TEST( strtoull ) -{ - char * endptr = NULL; - /* this, to base 36, overflows even a 256 bit integer */ - char overflow[] = "-ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ_"; - /* tricky border case */ - char tricky[] = "+0xz"; - errno = 0; - - /* basic functionality */ - TESTCASE( strtoull( "123", NULL, 10 ) == 123 ); - /* proper detecting of default base 10 */ - TESTCASE( strtoull( "456", NULL, 0 ) == 456 ); - /* proper functioning to smaller base */ - TESTCASE( strtoull( "14", NULL, 8 ) == 12 ); - /* proper autodetecting of octal */ - TESTCASE( strtoull( "016", NULL, 0 ) == 14 ); - /* proper autodetecting of hexadecimal, lowercase 'x' */ - TESTCASE( strtoull( "0xFF", NULL, 0 ) == 255 ); - /* proper autodetecting of hexadecimal, uppercase 'X' */ - TESTCASE( strtoull( "0Xa1", NULL, 0 ) == 161 ); - - /* proper handling of border case: 0x followed by non-hexdigit */ - TESTCASE( - (strtoull(tricky, &endptr, 0) == 0) && - (endptr == tricky + 2) && - (errno == 0) ); - - /* proper handling of border case: 0 followed by non-octdigit */ - TESTCASE( - (strtoull(tricky, &endptr, 8) == 0) && - (endptr == tricky + 2) && - (errno == 0) ); - - /* overflowing subject sequence must still return proper endptr */ - TESTCASE( - (strtoull(overflow, &endptr, 36) == ULLONG_MAX) && - (errno == ERANGE) && - ((endptr - overflow) == 53) ); - - /* same for positive */ - TESTCASE( - (strtoull(overflow + 1, &endptr, 36) == ULLONG_MAX) && - (errno == ERANGE) && - ((endptr - overflow) == 53) ); - - /* testing skipping of leading whitespace */ - TESTCASE( strtoull( " \n\v\t\f789", NULL, 0 ) == 789 ); - - /* testing conversion failure */ - TESTCASE( (strtoull(overflow, &endptr, 10) == 0) && (endptr == overflow) ); - TESTCASE( (strtoull(overflow, &endptr, 0) == 0) && (endptr == overflow) ); -/* long long -> 64 bit */ -#if __SIZEOF_LONG_LONG__ == 8 - /* testing "even" overflow, i.e. base is power of two */ - TESTCASE( (strtoull("18446744073709551615", NULL, 0) == ULLONG_MAX) && (errno == 0) ); - TESTCASE( (strtoull("18446744073709551616", NULL, 0) == ULLONG_MAX) && (errno == ERANGE) ); - /* TODO: test "odd" overflow, i.e. base is not power of two */ -/* long long -> 128 bit */ -#elif __SIZEOF_LONG_LONG__ == 16 - /* testing "even" overflow, i.e. base is power of two */ - TESTCASE( (strtoull("340282366920938463463374607431768211455", NULL, 0) == ULLONG_MAX) && (errno == 0) ); - TESTCASE( (strtoull("340282366920938463463374607431768211456", NULL, 0) == ULLONG_MAX) && (errno == ERANGE) ); - /* TODO: test "odd" overflow, i.e. base is not power of two */ -#else -#error Unsupported width of 'long long' (neither 64 nor 128 bit). -#endif -} -END_TEST - - -#define SYSTEM_MESSAGE "SUCCESS testing system()" -#define SYSTEM_COMMAND "echo '" SYSTEM_MESSAGE "'" - -START_TEST( system ) -{ - FILE * fh; - char buffer[25]; - buffer[24] = 'x'; - TESTCASE( ( fh = freopen( testfile, "wb+", stdout ) ) != NULL ); - TESTCASE( system( SYSTEM_COMMAND ) ); - rewind( fh ); - TESTCASE( fread( buffer, 1, 24, fh ) == 24 ); - TESTCASE( memcmp( buffer, SYSTEM_MESSAGE, 24 ) == 0 ); - TESTCASE( buffer[24] == 'x' ); - TESTCASE( fclose( fh ) == 0 ); - TESTCASE( remove( testfile ) == 0 ); -} -END_TEST - -START_SUITE( stdlib ) -{ - RUN_TEST( _Exit ); - RUN_TEST( abort ); - RUN_TEST( abs ); - RUN_TEST( atexit ); - RUN_TEST( bsearch ); - RUN_TEST( div ); - RUN_TEST( getenv ); - RUN_TEST( labs ); - RUN_TEST( ldiv ); - RUN_TEST( llabs ); - RUN_TEST( lldiv ); - RUN_TEST( qsort ); - RUN_TEST( strtol ); - RUN_TEST( strtoll ); - RUN_TEST( strtoul ); - RUN_TEST( strtoull ); - RUN_TEST( system ); -} -END_SUITE diff --git a/src/libraries/libc/tests/test_string.c b/src/libraries/libc/tests/test_string.c deleted file mode 100644 index eb96353..0000000 --- a/src/libraries/libc/tests/test_string.c +++ /dev/null @@ -1,386 +0,0 @@ -#include "_PDCLIB_test.h" - -START_TEST( memchr ) -{ - TESTCASE( memchr( abcde, 'c', 5 ) == &abcde[2] ); - TESTCASE( memchr( abcde, 'a', 1 ) == &abcde[0] ); - TESTCASE( memchr( abcde, 'a', 0 ) == NULL ); - TESTCASE( memchr( abcde, '\0', 5 ) == NULL ); - TESTCASE( memchr( abcde, '\0', 6 ) == &abcde[5] ); -} -END_TEST - -START_TEST( memcmp ) -{ - const char xxxxx[] = "xxxxx"; - TESTCASE( memcmp( abcde, abcdx, 5 ) < 0 ); - TESTCASE( memcmp( abcde, abcdx, 4 ) == 0 ); - TESTCASE( memcmp( abcde, xxxxx, 0 ) == 0 ); - TESTCASE( memcmp( xxxxx, abcde, 1 ) > 0 ); -} -END_TEST - -START_TEST( memcpy ) -{ - char s[] = "xxxxxxxxxxx"; - char *r = memcpy(s, abcde, 6); - TESTCASE( r == s ); - TESTCASE( s[4] == 'e' ); - TESTCASE( s[5] == '\0' ); - - r = memcpy(s + 5, abcde, 5); - TESTCASE( r == s + 5 ); - TESTCASE( s[9] == 'e' ); - TESTCASE( s[10] == 'x' ); -} -END_TEST - -START_TEST( memmove ) -{ - char s[] = "xxxxabcde"; - char *r = memmove(s, s + 4, 5); - TESTCASE( r == s ); - TESTCASE( s[0] == 'a' ); - TESTCASE( s[4] == 'e' ); - TESTCASE( s[5] == 'b' ); - - r = memmove(s + 4, s, 5); - TESTCASE( r == s + 4 ); - TESTCASE( s[4] == 'a' ); -} -END_TEST - -START_TEST( memset ) -{ - char s[] = "xxxxxxxxx"; - void *r = memset(s, 'o', 10); - TESTCASE( r == s ); - TESTCASE( s[9] == 'o' ); - - r = memset(s, '_', 0); - TESTCASE( r == s ); - TESTCASE( s[0] == 'o' ); - - r = memset(s, '_', 1); - TESTCASE( r == s ); - TESTCASE( s[0] == '_' ); - TESTCASE( s[1] == 'o' ); -} -END_TEST - -START_TEST( strcat ) -{ - char s[] = "xx\0xxxxxx"; - char *r = strcat(s, abcde); - TESTCASE( r == s ); - TESTCASE( s[2] == 'a' ); - TESTCASE( s[6] == 'e' ); - TESTCASE( s[7] == '\0' ); - TESTCASE( s[8] == 'x' ); - - s[0] = '\0'; - r = strcat(s, abcdx); - TESTCASE( r == s ); - TESTCASE( s[4] == 'x' ); - TESTCASE( s[5] == '\0' ); - - r = strcat(s, "\0"); - TESTCASE( r == s ); - TESTCASE( s[5] == '\0' ); - TESTCASE( s[6] == 'e' ); -} -END_TEST - -START_TEST( strchr ) -{ - char abccd[] = "abccd"; - TESTCASE( strchr( abccd, 'x' ) == NULL ); - TESTCASE( strchr( abccd, 'a' ) == &abccd[0] ); - TESTCASE( strchr( abccd, 'd' ) == &abccd[4] ); - TESTCASE( strchr( abccd, '\0' ) == &abccd[5] ); - TESTCASE( strchr( abccd, 'c' ) == &abccd[2] ); -} -END_TEST - -START_TEST( strcmp ) -{ - char cmpabcde[] = "abcde"; - char cmpabcd_[] = "abcd\xfc"; - char empty[] = ""; - TESTCASE( strcmp( abcde, cmpabcde ) == 0 ); - TESTCASE( strcmp( abcde, abcdx ) < 0 ); - TESTCASE( strcmp( abcdx, abcde ) > 0 ); - TESTCASE( strcmp( empty, abcde ) < 0 ); - TESTCASE( strcmp( abcde, empty ) > 0 ); - TESTCASE( strcmp( abcde, cmpabcd_ ) < 0 ); -} -END_TEST - -START_TEST( strcoll ) -{ - char cmpabcde[] = "abcde"; - char empty[] = ""; - TESTCASE( strcoll( abcde, cmpabcde ) == 0 ); - TESTCASE( strcoll( abcde, abcdx ) < 0 ); - TESTCASE( strcoll( abcdx, abcde ) > 0 ); - TESTCASE( strcoll( empty, abcde ) < 0 ); - TESTCASE( strcoll( abcde, empty ) > 0 ); -} -END_TEST - -START_TEST( strcpy ) -{ - char s[] = "xxxxx"; - char *r = strcpy(s, ""); - TESTCASE( r == s ); - TESTCASE( s[0] == '\0' ); - TESTCASE( s[1] == 'x' ); - - r = strcpy(s, abcde); - TESTCASE( r == s ); - TESTCASE( s[0] == 'a' ); - TESTCASE( s[4] == 'e' ); - TESTCASE( s[5] == '\0' ); -} -END_TEST - -START_TEST( strcspn ) -{ - TESTCASE( strcspn( abcde, "x" ) == 5 ); - TESTCASE( strcspn( abcde, "xyz" ) == 5 ); - TESTCASE( strcspn( abcde, "zyx" ) == 5 ); - TESTCASE( strcspn( abcdx, "x" ) == 4 ); - TESTCASE( strcspn( abcdx, "xyz" ) == 4 ); - TESTCASE( strcspn( abcdx, "zyx" ) == 4 ); - TESTCASE( strcspn( abcde, "a" ) == 0 ); - TESTCASE( strcspn( abcde, "abc" ) == 0 ); - TESTCASE( strcspn( abcde, "cba" ) == 0 ); -} -END_TEST - -START_TEST( strerror ) -{ - TESTCASE( strerror(ERANGE) != strerror(EDOM) ); -} -END_TEST - -START_TEST( strlen ) -{ - TESTCASE( strlen( abcde ) == 5 ); - TESTCASE( strlen( "" ) == 0 ); -} -END_TEST - -START_TEST( strncat ) -{ - char s[] = "xx\0xxxxxx"; - char *r = strncat(s, abcde, 10); - TESTCASE( r == s ); - TESTCASE( s[2] == 'a' ); - TESTCASE( s[6] == 'e' ); - TESTCASE( s[7] == '\0' ); - TESTCASE( s[8] == 'x' ); - - s[0] = '\0'; - r = strncat(s, abcdx, 10); - TESTCASE( r == s ); - TESTCASE( s[4] == 'x' ); - TESTCASE( s[5] == '\0' ); - - r = strncat(s, "\0", 10); - TESTCASE( r == s ); - TESTCASE( s[5] == '\0' ); - TESTCASE( s[6] == 'e' ); - - r = strncat(s, abcde, 0); - TESTCASE( r == s ); - TESTCASE( s[5] == '\0' ); - TESTCASE( s[6] == 'e' ); - - r = strncat(s, abcde, 3); - TESTCASE( r == s ); - TESTCASE( s[5] == 'a' ); - TESTCASE( s[7] == 'c' ); - TESTCASE( s[8] == '\0' ); -} -END_TEST - -START_TEST( strncmp ) -{ - char cmpabcde[] = "abcde\0f"; - char cmpabcd_[] = "abcde\xfc"; - char empty[] = ""; - char x[] = "x"; - TESTCASE( strncmp( abcde, cmpabcde, 5 ) == 0 ); - TESTCASE( strncmp( abcde, cmpabcde, 10 ) == 0 ); - TESTCASE( strncmp( abcde, abcdx, 5 ) < 0 ); - TESTCASE( strncmp( abcdx, abcde, 5 ) > 0 ); - TESTCASE( strncmp( empty, abcde, 5 ) < 0 ); - TESTCASE( strncmp( abcde, empty, 5 ) > 0 ); - TESTCASE( strncmp( abcde, abcdx, 4 ) == 0 ); - TESTCASE( strncmp( abcde, x, 0 ) == 0 ); - TESTCASE( strncmp( abcde, x, 1 ) < 0 ); - TESTCASE( strncmp( abcde, cmpabcd_, 10 ) < 0 ); -} -END_TEST - -START_TEST( strncpy ) -{ - char s[] = "xxxxxxx"; - char *r = strncpy(s, "", 1); - TESTCASE( r == s ); - TESTCASE( s[0] == '\0' ); - TESTCASE( s[1] == 'x' ); - - r = strncpy(s, abcde, 6); - TESTCASE( r == s ); - TESTCASE( s[0] == 'a' ); - TESTCASE( s[4] == 'e' ); - TESTCASE( s[5] == '\0' ); - TESTCASE( s[6] == 'x' ); - - r = strncpy(s, abcde, 7); - TESTCASE( r == s ); - TESTCASE( s[6] == '\0' ); - - r = strncpy(s, "xxxx", 3); - TESTCASE( r == s ); - TESTCASE( s[0] == 'x' ); - TESTCASE( s[2] == 'x' ); - TESTCASE( s[3] == 'd' ); -} -END_TEST - -START_TEST( strpbrk ) -{ - TESTCASE( strpbrk( abcde, "x" ) == NULL ); - TESTCASE( strpbrk( abcde, "xyz" ) == NULL ); - TESTCASE( strpbrk( abcdx, "x" ) == &abcdx[4] ); - TESTCASE( strpbrk( abcdx, "xyz" ) == &abcdx[4] ); - TESTCASE( strpbrk( abcdx, "zyx" ) == &abcdx[4] ); - TESTCASE( strpbrk( abcde, "a" ) == &abcde[0] ); - TESTCASE( strpbrk( abcde, "abc" ) == &abcde[0] ); - TESTCASE( strpbrk( abcde, "cba" ) == &abcde[0] ); -} -END_TEST - -START_TEST( strrchr ) -{ - char abccd[] = "abccd"; - TESTCASE( strrchr( abcde, '\0' ) == &abcde[5] ); - TESTCASE( strrchr( abcde, 'e' ) == &abcde[4] ); - TESTCASE( strrchr( abcde, 'a' ) == &abcde[0] ); - TESTCASE( strrchr( abccd, 'c' ) == &abccd[3] ); -} -END_TEST - -START_TEST( strspn ) -{ - TESTCASE( strspn( abcde, "abc" ) == 3 ); - TESTCASE( strspn( abcde, "b" ) == 0 ); - TESTCASE( strspn( abcde, abcde ) == 5 ); -} -END_TEST - -START_TEST( strstr ) -{ - char s[] = "abcabcabcdabcde"; - TESTCASE( strstr( s, "x" ) == NULL ); - TESTCASE( strstr( s, "xyz" ) == NULL ); - TESTCASE( strstr( s, "a" ) == &s[0] ); - TESTCASE( strstr( s, "abc" ) == &s[0] ); - TESTCASE( strstr( s, "abcd" ) == &s[6] ); - TESTCASE( strstr( s, "abcde" ) == &s[10] ); -} -END_TEST - -START_TEST( strtok ) -{ - char s[] = "_a_bc__d_"; - char *r = strtok(s, "_"); - TESTCASE( r == &s[1] ); - TESTCASE( s[1] == 'a' ); - TESTCASE( s[2] == '\0' ); - - r = strtok(NULL, "_"); - TESTCASE( r == &s[3] ); - TESTCASE( s[3] == 'b' ); - TESTCASE( s[4] == 'c' ); - TESTCASE( s[5] == '\0' ); - - r = strtok(NULL, "_"); - TESTCASE( r == &s[7] ); - TESTCASE( s[6] == '_' ); - TESTCASE( s[7] == 'd' ); - TESTCASE( s[8] == '\0' ); - - r = strtok(NULL, "_"); - TESTCASE( r == NULL ); - - strcpy( s, "ab_cd" ); - r = strtok(s, "_"); - TESTCASE( r == &s[0] ); - TESTCASE( s[0] == 'a' ); - TESTCASE( s[1] == 'b' ); - TESTCASE( s[2] == '\0' ); - - r = strtok(NULL, "_"); - TESTCASE( r == &s[3] ); - TESTCASE( s[3] == 'c' ); - TESTCASE( s[4] == 'd' ); - TESTCASE( s[5] == '\0' ); - - r = strtok(NULL, "_"); - TESTCASE( r == NULL ); -} -END_TEST - -START_TEST( strxfrm ) -{ - char s[] = "xxxxxxxxxxx"; - size_t r = strxfrm(NULL, "123456789012", 0); - TESTCASE( r == 12 ); - - r = strxfrm(s, "123456789012", 12); - TESTCASE( r == 12 ); - - /* - The following test case is true in *this* implementation, but doesn't have to. - TESTCASE( s[0] == 'x' ); - */ - - r = strxfrm(s, "1234567890", 11); - TESTCASE( r == 10 ); - TESTCASE( s[0] == '1' ); - TESTCASE( s[9] == '0' ); - TESTCASE( s[10] == '\0' ); -} -END_TEST - - -START_SUITE( string ) -{ - RUN_TEST( memchr ); - RUN_TEST( memcmp ); - RUN_TEST( memcpy ); - RUN_TEST( memmove ); - RUN_TEST( memset ); - RUN_TEST( strcat ); - RUN_TEST( strchr ); - RUN_TEST( strcmp ); - RUN_TEST( strcoll ); - RUN_TEST( strcpy ); - RUN_TEST( strcspn ); - RUN_TEST( strerror ); - RUN_TEST( strlen ); - RUN_TEST( strncat ); - RUN_TEST( strncmp ); - RUN_TEST( strncpy ); - RUN_TEST( strpbrk ); - RUN_TEST( strrchr ); - RUN_TEST( strspn ); - RUN_TEST( strstr ); - RUN_TEST( strtok ); - RUN_TEST( strxfrm ); -} -END_SUITE diff --git a/src/libraries/libc/tests/test_time.c b/src/libraries/libc/tests/test_time.c deleted file mode 100644 index e03147b..0000000 --- a/src/libraries/libc/tests/test_time.c +++ /dev/null @@ -1,1167 +0,0 @@ -#include "_PDCLIB_test.h" -#include - -#define MKTIME( tm, sec, min, hour, day, month, year, wday, yday ) tm.tm_sec = sec; tm.tm_min = min; tm.tm_hour = hour; tm.tm_mday = day; tm.tm_mon = month; tm.tm_year = year; tm.tm_wday = wday; tm.tm_yday = yday; tm.tm_isdst = -1; - -/* Test data generated by reference mktime() / strftime(), listing: - * tm_year - * tm_wday - * tm_yday - * '%U' result - * '%V' result - * '%W' result -*/ -int data[1020][6] = -{ -{ 70, 4, 0, 0, 1, 0 }, -{ 70, 5, 1, 0, 1, 0 }, -{ 70, 6, 2, 0, 1, 0 }, -{ 70, 0, 3, 1, 1, 0 }, -{ 70, 1, 4, 1, 2, 1 }, -{ 70, 2, 5, 1, 2, 1 }, -{ 70, 3, 6, 1, 2, 1 }, -{ 70, 4, 357, 51, 52, 51 }, -{ 70, 5, 358, 51, 52, 51 }, -{ 70, 6, 359, 51, 52, 51 }, -{ 70, 0, 360, 52, 52, 51 }, -{ 70, 1, 361, 52, 53, 52 }, -{ 70, 2, 362, 52, 53, 52 }, -{ 70, 3, 363, 52, 53, 52 }, -{ 70, 4, 364, 52, 53, 52 }, -{ 71, 5, 0, 0, 53, 0 }, -{ 71, 6, 1, 0, 53, 0 }, -{ 71, 0, 2, 1, 53, 0 }, -{ 71, 1, 3, 1, 1, 1 }, -{ 71, 2, 4, 1, 1, 1 }, -{ 71, 3, 5, 1, 1, 1 }, -{ 71, 4, 6, 1, 1, 1 }, -{ 71, 5, 357, 51, 51, 51 }, -{ 71, 6, 358, 51, 51, 51 }, -{ 71, 0, 359, 52, 51, 51 }, -{ 71, 1, 360, 52, 52, 52 }, -{ 71, 2, 361, 52, 52, 52 }, -{ 71, 3, 362, 52, 52, 52 }, -{ 71, 4, 363, 52, 52, 52 }, -{ 71, 5, 364, 52, 52, 52 }, -{ 72, 6, 0, 0, 52, 0 }, -{ 72, 0, 1, 1, 52, 0 }, -{ 72, 1, 2, 1, 1, 1 }, -{ 72, 2, 3, 1, 1, 1 }, -{ 72, 3, 4, 1, 1, 1 }, -{ 72, 4, 5, 1, 1, 1 }, -{ 72, 5, 6, 1, 1, 1 }, -{ 72, 0, 358, 52, 51, 51 }, -{ 72, 1, 359, 52, 52, 52 }, -{ 72, 2, 360, 52, 52, 52 }, -{ 72, 3, 361, 52, 52, 52 }, -{ 72, 4, 362, 52, 52, 52 }, -{ 72, 5, 363, 52, 52, 52 }, -{ 72, 6, 364, 52, 52, 52 }, -{ 72, 0, 365, 53, 52, 52 }, -{ 73, 1, 0, 0, 1, 1 }, -{ 73, 2, 1, 0, 1, 1 }, -{ 73, 3, 2, 0, 1, 1 }, -{ 73, 4, 3, 0, 1, 1 }, -{ 73, 5, 4, 0, 1, 1 }, -{ 73, 6, 5, 0, 1, 1 }, -{ 73, 0, 6, 1, 1, 1 }, -{ 73, 1, 357, 51, 52, 52 }, -{ 73, 2, 358, 51, 52, 52 }, -{ 73, 3, 359, 51, 52, 52 }, -{ 73, 4, 360, 51, 52, 52 }, -{ 73, 5, 361, 51, 52, 52 }, -{ 73, 6, 362, 51, 52, 52 }, -{ 73, 0, 363, 52, 52, 52 }, -{ 73, 1, 364, 52, 1, 53 }, -{ 74, 2, 0, 0, 1, 0 }, -{ 74, 3, 1, 0, 1, 0 }, -{ 74, 4, 2, 0, 1, 0 }, -{ 74, 5, 3, 0, 1, 0 }, -{ 74, 6, 4, 0, 1, 0 }, -{ 74, 0, 5, 1, 1, 0 }, -{ 74, 1, 6, 1, 2, 1 }, -{ 74, 2, 357, 51, 52, 51 }, -{ 74, 3, 358, 51, 52, 51 }, -{ 74, 4, 359, 51, 52, 51 }, -{ 74, 5, 360, 51, 52, 51 }, -{ 74, 6, 361, 51, 52, 51 }, -{ 74, 0, 362, 52, 52, 51 }, -{ 74, 1, 363, 52, 1, 52 }, -{ 74, 2, 364, 52, 1, 52 }, -{ 75, 3, 0, 0, 1, 0 }, -{ 75, 4, 1, 0, 1, 0 }, -{ 75, 5, 2, 0, 1, 0 }, -{ 75, 6, 3, 0, 1, 0 }, -{ 75, 0, 4, 1, 1, 0 }, -{ 75, 1, 5, 1, 2, 1 }, -{ 75, 2, 6, 1, 2, 1 }, -{ 75, 3, 357, 51, 52, 51 }, -{ 75, 4, 358, 51, 52, 51 }, -{ 75, 5, 359, 51, 52, 51 }, -{ 75, 6, 360, 51, 52, 51 }, -{ 75, 0, 361, 52, 52, 51 }, -{ 75, 1, 362, 52, 1, 52 }, -{ 75, 2, 363, 52, 1, 52 }, -{ 75, 3, 364, 52, 1, 52 }, -{ 76, 4, 0, 0, 1, 0 }, -{ 76, 5, 1, 0, 1, 0 }, -{ 76, 6, 2, 0, 1, 0 }, -{ 76, 0, 3, 1, 1, 0 }, -{ 76, 1, 4, 1, 2, 1 }, -{ 76, 2, 5, 1, 2, 1 }, -{ 76, 3, 6, 1, 2, 1 }, -{ 76, 5, 358, 51, 52, 51 }, -{ 76, 6, 359, 51, 52, 51 }, -{ 76, 0, 360, 52, 52, 51 }, -{ 76, 1, 361, 52, 53, 52 }, -{ 76, 2, 362, 52, 53, 52 }, -{ 76, 3, 363, 52, 53, 52 }, -{ 76, 4, 364, 52, 53, 52 }, -{ 76, 5, 365, 52, 53, 52 }, -{ 77, 6, 0, 0, 53, 0 }, -{ 77, 0, 1, 1, 53, 0 }, -{ 77, 1, 2, 1, 1, 1 }, -{ 77, 2, 3, 1, 1, 1 }, -{ 77, 3, 4, 1, 1, 1 }, -{ 77, 4, 5, 1, 1, 1 }, -{ 77, 5, 6, 1, 1, 1 }, -{ 77, 6, 357, 51, 51, 51 }, -{ 77, 0, 358, 52, 51, 51 }, -{ 77, 1, 359, 52, 52, 52 }, -{ 77, 2, 360, 52, 52, 52 }, -{ 77, 3, 361, 52, 52, 52 }, -{ 77, 4, 362, 52, 52, 52 }, -{ 77, 5, 363, 52, 52, 52 }, -{ 77, 6, 364, 52, 52, 52 }, -{ 78, 0, 0, 1, 52, 0 }, -{ 78, 1, 1, 1, 1, 1 }, -{ 78, 2, 2, 1, 1, 1 }, -{ 78, 3, 3, 1, 1, 1 }, -{ 78, 4, 4, 1, 1, 1 }, -{ 78, 5, 5, 1, 1, 1 }, -{ 78, 6, 6, 1, 1, 1 }, -{ 78, 0, 357, 52, 51, 51 }, -{ 78, 1, 358, 52, 52, 52 }, -{ 78, 2, 359, 52, 52, 52 }, -{ 78, 3, 360, 52, 52, 52 }, -{ 78, 4, 361, 52, 52, 52 }, -{ 78, 5, 362, 52, 52, 52 }, -{ 78, 6, 363, 52, 52, 52 }, -{ 78, 0, 364, 53, 52, 52 }, -{ 79, 1, 0, 0, 1, 1 }, -{ 79, 2, 1, 0, 1, 1 }, -{ 79, 3, 2, 0, 1, 1 }, -{ 79, 4, 3, 0, 1, 1 }, -{ 79, 5, 4, 0, 1, 1 }, -{ 79, 6, 5, 0, 1, 1 }, -{ 79, 0, 6, 1, 1, 1 }, -{ 79, 1, 357, 51, 52, 52 }, -{ 79, 2, 358, 51, 52, 52 }, -{ 79, 3, 359, 51, 52, 52 }, -{ 79, 4, 360, 51, 52, 52 }, -{ 79, 5, 361, 51, 52, 52 }, -{ 79, 6, 362, 51, 52, 52 }, -{ 79, 0, 363, 52, 52, 52 }, -{ 79, 1, 364, 52, 1, 53 }, -{ 80, 2, 0, 0, 1, 0 }, -{ 80, 3, 1, 0, 1, 0 }, -{ 80, 4, 2, 0, 1, 0 }, -{ 80, 5, 3, 0, 1, 0 }, -{ 80, 6, 4, 0, 1, 0 }, -{ 80, 0, 5, 1, 1, 0 }, -{ 80, 1, 6, 1, 2, 1 }, -{ 80, 3, 358, 51, 52, 51 }, -{ 80, 4, 359, 51, 52, 51 }, -{ 80, 5, 360, 51, 52, 51 }, -{ 80, 6, 361, 51, 52, 51 }, -{ 80, 0, 362, 52, 52, 51 }, -{ 80, 1, 363, 52, 1, 52 }, -{ 80, 2, 364, 52, 1, 52 }, -{ 80, 3, 365, 52, 1, 52 }, -{ 81, 4, 0, 0, 1, 0 }, -{ 81, 5, 1, 0, 1, 0 }, -{ 81, 6, 2, 0, 1, 0 }, -{ 81, 0, 3, 1, 1, 0 }, -{ 81, 1, 4, 1, 2, 1 }, -{ 81, 2, 5, 1, 2, 1 }, -{ 81, 3, 6, 1, 2, 1 }, -{ 81, 4, 357, 51, 52, 51 }, -{ 81, 5, 358, 51, 52, 51 }, -{ 81, 6, 359, 51, 52, 51 }, -{ 81, 0, 360, 52, 52, 51 }, -{ 81, 1, 361, 52, 53, 52 }, -{ 81, 2, 362, 52, 53, 52 }, -{ 81, 3, 363, 52, 53, 52 }, -{ 81, 4, 364, 52, 53, 52 }, -{ 82, 5, 0, 0, 53, 0 }, -{ 82, 6, 1, 0, 53, 0 }, -{ 82, 0, 2, 1, 53, 0 }, -{ 82, 1, 3, 1, 1, 1 }, -{ 82, 2, 4, 1, 1, 1 }, -{ 82, 3, 5, 1, 1, 1 }, -{ 82, 4, 6, 1, 1, 1 }, -{ 82, 5, 357, 51, 51, 51 }, -{ 82, 6, 358, 51, 51, 51 }, -{ 82, 0, 359, 52, 51, 51 }, -{ 82, 1, 360, 52, 52, 52 }, -{ 82, 2, 361, 52, 52, 52 }, -{ 82, 3, 362, 52, 52, 52 }, -{ 82, 4, 363, 52, 52, 52 }, -{ 82, 5, 364, 52, 52, 52 }, -{ 83, 6, 0, 0, 52, 0 }, -{ 83, 0, 1, 1, 52, 0 }, -{ 83, 1, 2, 1, 1, 1 }, -{ 83, 2, 3, 1, 1, 1 }, -{ 83, 3, 4, 1, 1, 1 }, -{ 83, 4, 5, 1, 1, 1 }, -{ 83, 5, 6, 1, 1, 1 }, -{ 83, 6, 357, 51, 51, 51 }, -{ 83, 0, 358, 52, 51, 51 }, -{ 83, 1, 359, 52, 52, 52 }, -{ 83, 2, 360, 52, 52, 52 }, -{ 83, 3, 361, 52, 52, 52 }, -{ 83, 4, 362, 52, 52, 52 }, -{ 83, 5, 363, 52, 52, 52 }, -{ 83, 6, 364, 52, 52, 52 }, -{ 84, 0, 0, 1, 52, 0 }, -{ 84, 1, 1, 1, 1, 1 }, -{ 84, 2, 2, 1, 1, 1 }, -{ 84, 3, 3, 1, 1, 1 }, -{ 84, 4, 4, 1, 1, 1 }, -{ 84, 5, 5, 1, 1, 1 }, -{ 84, 6, 6, 1, 1, 1 }, -{ 84, 1, 358, 52, 52, 52 }, -{ 84, 2, 359, 52, 52, 52 }, -{ 84, 3, 360, 52, 52, 52 }, -{ 84, 4, 361, 52, 52, 52 }, -{ 84, 5, 362, 52, 52, 52 }, -{ 84, 6, 363, 52, 52, 52 }, -{ 84, 0, 364, 53, 52, 52 }, -{ 84, 1, 365, 53, 1, 53 }, -{ 85, 2, 0, 0, 1, 0 }, -{ 85, 3, 1, 0, 1, 0 }, -{ 85, 4, 2, 0, 1, 0 }, -{ 85, 5, 3, 0, 1, 0 }, -{ 85, 6, 4, 0, 1, 0 }, -{ 85, 0, 5, 1, 1, 0 }, -{ 85, 1, 6, 1, 2, 1 }, -{ 85, 2, 357, 51, 52, 51 }, -{ 85, 3, 358, 51, 52, 51 }, -{ 85, 4, 359, 51, 52, 51 }, -{ 85, 5, 360, 51, 52, 51 }, -{ 85, 6, 361, 51, 52, 51 }, -{ 85, 0, 362, 52, 52, 51 }, -{ 85, 1, 363, 52, 1, 52 }, -{ 85, 2, 364, 52, 1, 52 }, -{ 86, 3, 0, 0, 1, 0 }, -{ 86, 4, 1, 0, 1, 0 }, -{ 86, 5, 2, 0, 1, 0 }, -{ 86, 6, 3, 0, 1, 0 }, -{ 86, 0, 4, 1, 1, 0 }, -{ 86, 1, 5, 1, 2, 1 }, -{ 86, 2, 6, 1, 2, 1 }, -{ 86, 3, 357, 51, 52, 51 }, -{ 86, 4, 358, 51, 52, 51 }, -{ 86, 5, 359, 51, 52, 51 }, -{ 86, 6, 360, 51, 52, 51 }, -{ 86, 0, 361, 52, 52, 51 }, -{ 86, 1, 362, 52, 1, 52 }, -{ 86, 2, 363, 52, 1, 52 }, -{ 86, 3, 364, 52, 1, 52 }, -{ 87, 4, 0, 0, 1, 0 }, -{ 87, 5, 1, 0, 1, 0 }, -{ 87, 6, 2, 0, 1, 0 }, -{ 87, 0, 3, 1, 1, 0 }, -{ 87, 1, 4, 1, 2, 1 }, -{ 87, 2, 5, 1, 2, 1 }, -{ 87, 3, 6, 1, 2, 1 }, -{ 87, 4, 357, 51, 52, 51 }, -{ 87, 5, 358, 51, 52, 51 }, -{ 87, 6, 359, 51, 52, 51 }, -{ 87, 0, 360, 52, 52, 51 }, -{ 87, 1, 361, 52, 53, 52 }, -{ 87, 2, 362, 52, 53, 52 }, -{ 87, 3, 363, 52, 53, 52 }, -{ 87, 4, 364, 52, 53, 52 }, -{ 88, 5, 0, 0, 53, 0 }, -{ 88, 6, 1, 0, 53, 0 }, -{ 88, 0, 2, 1, 53, 0 }, -{ 88, 1, 3, 1, 1, 1 }, -{ 88, 2, 4, 1, 1, 1 }, -{ 88, 3, 5, 1, 1, 1 }, -{ 88, 4, 6, 1, 1, 1 }, -{ 88, 6, 358, 51, 51, 51 }, -{ 88, 0, 359, 52, 51, 51 }, -{ 88, 1, 360, 52, 52, 52 }, -{ 88, 2, 361, 52, 52, 52 }, -{ 88, 3, 362, 52, 52, 52 }, -{ 88, 4, 363, 52, 52, 52 }, -{ 88, 5, 364, 52, 52, 52 }, -{ 88, 6, 365, 52, 52, 52 }, -{ 89, 0, 0, 1, 52, 0 }, -{ 89, 1, 1, 1, 1, 1 }, -{ 89, 2, 2, 1, 1, 1 }, -{ 89, 3, 3, 1, 1, 1 }, -{ 89, 4, 4, 1, 1, 1 }, -{ 89, 5, 5, 1, 1, 1 }, -{ 89, 6, 6, 1, 1, 1 }, -{ 89, 0, 357, 52, 51, 51 }, -{ 89, 1, 358, 52, 52, 52 }, -{ 89, 2, 359, 52, 52, 52 }, -{ 89, 3, 360, 52, 52, 52 }, -{ 89, 4, 361, 52, 52, 52 }, -{ 89, 5, 362, 52, 52, 52 }, -{ 89, 6, 363, 52, 52, 52 }, -{ 89, 0, 364, 53, 52, 52 }, -{ 90, 1, 0, 0, 1, 1 }, -{ 90, 2, 1, 0, 1, 1 }, -{ 90, 3, 2, 0, 1, 1 }, -{ 90, 4, 3, 0, 1, 1 }, -{ 90, 5, 4, 0, 1, 1 }, -{ 90, 6, 5, 0, 1, 1 }, -{ 90, 0, 6, 1, 1, 1 }, -{ 90, 1, 357, 51, 52, 52 }, -{ 90, 2, 358, 51, 52, 52 }, -{ 90, 3, 359, 51, 52, 52 }, -{ 90, 4, 360, 51, 52, 52 }, -{ 90, 5, 361, 51, 52, 52 }, -{ 90, 6, 362, 51, 52, 52 }, -{ 90, 0, 363, 52, 52, 52 }, -{ 90, 1, 364, 52, 1, 53 }, -{ 91, 2, 0, 0, 1, 0 }, -{ 91, 3, 1, 0, 1, 0 }, -{ 91, 4, 2, 0, 1, 0 }, -{ 91, 5, 3, 0, 1, 0 }, -{ 91, 6, 4, 0, 1, 0 }, -{ 91, 0, 5, 1, 1, 0 }, -{ 91, 1, 6, 1, 2, 1 }, -{ 91, 2, 357, 51, 52, 51 }, -{ 91, 3, 358, 51, 52, 51 }, -{ 91, 4, 359, 51, 52, 51 }, -{ 91, 5, 360, 51, 52, 51 }, -{ 91, 6, 361, 51, 52, 51 }, -{ 91, 0, 362, 52, 52, 51 }, -{ 91, 1, 363, 52, 1, 52 }, -{ 91, 2, 364, 52, 1, 52 }, -{ 92, 3, 0, 0, 1, 0 }, -{ 92, 4, 1, 0, 1, 0 }, -{ 92, 5, 2, 0, 1, 0 }, -{ 92, 6, 3, 0, 1, 0 }, -{ 92, 0, 4, 1, 1, 0 }, -{ 92, 1, 5, 1, 2, 1 }, -{ 92, 2, 6, 1, 2, 1 }, -{ 92, 4, 358, 51, 52, 51 }, -{ 92, 5, 359, 51, 52, 51 }, -{ 92, 6, 360, 51, 52, 51 }, -{ 92, 0, 361, 52, 52, 51 }, -{ 92, 1, 362, 52, 53, 52 }, -{ 92, 2, 363, 52, 53, 52 }, -{ 92, 3, 364, 52, 53, 52 }, -{ 92, 4, 365, 52, 53, 52 }, -{ 93, 5, 0, 0, 53, 0 }, -{ 93, 6, 1, 0, 53, 0 }, -{ 93, 0, 2, 1, 53, 0 }, -{ 93, 1, 3, 1, 1, 1 }, -{ 93, 2, 4, 1, 1, 1 }, -{ 93, 3, 5, 1, 1, 1 }, -{ 93, 4, 6, 1, 1, 1 }, -{ 93, 5, 357, 51, 51, 51 }, -{ 93, 6, 358, 51, 51, 51 }, -{ 93, 0, 359, 52, 51, 51 }, -{ 93, 1, 360, 52, 52, 52 }, -{ 93, 2, 361, 52, 52, 52 }, -{ 93, 3, 362, 52, 52, 52 }, -{ 93, 4, 363, 52, 52, 52 }, -{ 93, 5, 364, 52, 52, 52 }, -{ 94, 6, 0, 0, 52, 0 }, -{ 94, 0, 1, 1, 52, 0 }, -{ 94, 1, 2, 1, 1, 1 }, -{ 94, 2, 3, 1, 1, 1 }, -{ 94, 3, 4, 1, 1, 1 }, -{ 94, 4, 5, 1, 1, 1 }, -{ 94, 5, 6, 1, 1, 1 }, -{ 94, 6, 357, 51, 51, 51 }, -{ 94, 0, 358, 52, 51, 51 }, -{ 94, 1, 359, 52, 52, 52 }, -{ 94, 2, 360, 52, 52, 52 }, -{ 94, 3, 361, 52, 52, 52 }, -{ 94, 4, 362, 52, 52, 52 }, -{ 94, 5, 363, 52, 52, 52 }, -{ 94, 6, 364, 52, 52, 52 }, -{ 95, 0, 0, 1, 52, 0 }, -{ 95, 1, 1, 1, 1, 1 }, -{ 95, 2, 2, 1, 1, 1 }, -{ 95, 3, 3, 1, 1, 1 }, -{ 95, 4, 4, 1, 1, 1 }, -{ 95, 5, 5, 1, 1, 1 }, -{ 95, 6, 6, 1, 1, 1 }, -{ 95, 0, 357, 52, 51, 51 }, -{ 95, 1, 358, 52, 52, 52 }, -{ 95, 2, 359, 52, 52, 52 }, -{ 95, 3, 360, 52, 52, 52 }, -{ 95, 4, 361, 52, 52, 52 }, -{ 95, 5, 362, 52, 52, 52 }, -{ 95, 6, 363, 52, 52, 52 }, -{ 95, 0, 364, 53, 52, 52 }, -{ 96, 1, 0, 0, 1, 1 }, -{ 96, 2, 1, 0, 1, 1 }, -{ 96, 3, 2, 0, 1, 1 }, -{ 96, 4, 3, 0, 1, 1 }, -{ 96, 5, 4, 0, 1, 1 }, -{ 96, 6, 5, 0, 1, 1 }, -{ 96, 0, 6, 1, 1, 1 }, -{ 96, 2, 358, 51, 52, 52 }, -{ 96, 3, 359, 51, 52, 52 }, -{ 96, 4, 360, 51, 52, 52 }, -{ 96, 5, 361, 51, 52, 52 }, -{ 96, 6, 362, 51, 52, 52 }, -{ 96, 0, 363, 52, 52, 52 }, -{ 96, 1, 364, 52, 1, 53 }, -{ 96, 2, 365, 52, 1, 53 }, -{ 97, 3, 0, 0, 1, 0 }, -{ 97, 4, 1, 0, 1, 0 }, -{ 97, 5, 2, 0, 1, 0 }, -{ 97, 6, 3, 0, 1, 0 }, -{ 97, 0, 4, 1, 1, 0 }, -{ 97, 1, 5, 1, 2, 1 }, -{ 97, 2, 6, 1, 2, 1 }, -{ 97, 3, 357, 51, 52, 51 }, -{ 97, 4, 358, 51, 52, 51 }, -{ 97, 5, 359, 51, 52, 51 }, -{ 97, 6, 360, 51, 52, 51 }, -{ 97, 0, 361, 52, 52, 51 }, -{ 97, 1, 362, 52, 1, 52 }, -{ 97, 2, 363, 52, 1, 52 }, -{ 97, 3, 364, 52, 1, 52 }, -{ 98, 4, 0, 0, 1, 0 }, -{ 98, 5, 1, 0, 1, 0 }, -{ 98, 6, 2, 0, 1, 0 }, -{ 98, 0, 3, 1, 1, 0 }, -{ 98, 1, 4, 1, 2, 1 }, -{ 98, 2, 5, 1, 2, 1 }, -{ 98, 3, 6, 1, 2, 1 }, -{ 98, 4, 357, 51, 52, 51 }, -{ 98, 5, 358, 51, 52, 51 }, -{ 98, 6, 359, 51, 52, 51 }, -{ 98, 0, 360, 52, 52, 51 }, -{ 98, 1, 361, 52, 53, 52 }, -{ 98, 2, 362, 52, 53, 52 }, -{ 98, 3, 363, 52, 53, 52 }, -{ 98, 4, 364, 52, 53, 52 }, -{ 99, 5, 0, 0, 53, 0 }, -{ 99, 6, 1, 0, 53, 0 }, -{ 99, 0, 2, 1, 53, 0 }, -{ 99, 1, 3, 1, 1, 1 }, -{ 99, 2, 4, 1, 1, 1 }, -{ 99, 3, 5, 1, 1, 1 }, -{ 99, 4, 6, 1, 1, 1 }, -{ 99, 5, 357, 51, 51, 51 }, -{ 99, 6, 358, 51, 51, 51 }, -{ 99, 0, 359, 52, 51, 51 }, -{ 99, 1, 360, 52, 52, 52 }, -{ 99, 2, 361, 52, 52, 52 }, -{ 99, 3, 362, 52, 52, 52 }, -{ 99, 4, 363, 52, 52, 52 }, -{ 99, 5, 364, 52, 52, 52 }, -{ 100, 6, 0, 0, 52, 0 }, -{ 100, 0, 1, 1, 52, 0 }, -{ 100, 1, 2, 1, 1, 1 }, -{ 100, 2, 3, 1, 1, 1 }, -{ 100, 3, 4, 1, 1, 1 }, -{ 100, 4, 5, 1, 1, 1 }, -{ 100, 5, 6, 1, 1, 1 }, -{ 100, 0, 358, 52, 51, 51 }, -{ 100, 1, 359, 52, 52, 52 }, -{ 100, 2, 360, 52, 52, 52 }, -{ 100, 3, 361, 52, 52, 52 }, -{ 100, 4, 362, 52, 52, 52 }, -{ 100, 5, 363, 52, 52, 52 }, -{ 100, 6, 364, 52, 52, 52 }, -{ 100, 0, 365, 53, 52, 52 }, -{ 101, 1, 0, 0, 1, 1 }, -{ 101, 2, 1, 0, 1, 1 }, -{ 101, 3, 2, 0, 1, 1 }, -{ 101, 4, 3, 0, 1, 1 }, -{ 101, 5, 4, 0, 1, 1 }, -{ 101, 6, 5, 0, 1, 1 }, -{ 101, 0, 6, 1, 1, 1 }, -{ 101, 1, 357, 51, 52, 52 }, -{ 101, 2, 358, 51, 52, 52 }, -{ 101, 3, 359, 51, 52, 52 }, -{ 101, 4, 360, 51, 52, 52 }, -{ 101, 5, 361, 51, 52, 52 }, -{ 101, 6, 362, 51, 52, 52 }, -{ 101, 0, 363, 52, 52, 52 }, -{ 101, 1, 364, 52, 1, 53 }, -{ 102, 2, 0, 0, 1, 0 }, -{ 102, 3, 1, 0, 1, 0 }, -{ 102, 4, 2, 0, 1, 0 }, -{ 102, 5, 3, 0, 1, 0 }, -{ 102, 6, 4, 0, 1, 0 }, -{ 102, 0, 5, 1, 1, 0 }, -{ 102, 1, 6, 1, 2, 1 }, -{ 102, 2, 357, 51, 52, 51 }, -{ 102, 3, 358, 51, 52, 51 }, -{ 102, 4, 359, 51, 52, 51 }, -{ 102, 5, 360, 51, 52, 51 }, -{ 102, 6, 361, 51, 52, 51 }, -{ 102, 0, 362, 52, 52, 51 }, -{ 102, 1, 363, 52, 1, 52 }, -{ 102, 2, 364, 52, 1, 52 }, -{ 103, 3, 0, 0, 1, 0 }, -{ 103, 4, 1, 0, 1, 0 }, -{ 103, 5, 2, 0, 1, 0 }, -{ 103, 6, 3, 0, 1, 0 }, -{ 103, 0, 4, 1, 1, 0 }, -{ 103, 1, 5, 1, 2, 1 }, -{ 103, 2, 6, 1, 2, 1 }, -{ 103, 3, 357, 51, 52, 51 }, -{ 103, 4, 358, 51, 52, 51 }, -{ 103, 5, 359, 51, 52, 51 }, -{ 103, 6, 360, 51, 52, 51 }, -{ 103, 0, 361, 52, 52, 51 }, -{ 103, 1, 362, 52, 1, 52 }, -{ 103, 2, 363, 52, 1, 52 }, -{ 103, 3, 364, 52, 1, 52 }, -{ 104, 4, 0, 0, 1, 0 }, -{ 104, 5, 1, 0, 1, 0 }, -{ 104, 6, 2, 0, 1, 0 }, -{ 104, 0, 3, 1, 1, 0 }, -{ 104, 1, 4, 1, 2, 1 }, -{ 104, 2, 5, 1, 2, 1 }, -{ 104, 3, 6, 1, 2, 1 }, -{ 104, 5, 358, 51, 52, 51 }, -{ 104, 6, 359, 51, 52, 51 }, -{ 104, 0, 360, 52, 52, 51 }, -{ 104, 1, 361, 52, 53, 52 }, -{ 104, 2, 362, 52, 53, 52 }, -{ 104, 3, 363, 52, 53, 52 }, -{ 104, 4, 364, 52, 53, 52 }, -{ 104, 5, 365, 52, 53, 52 }, -{ 105, 6, 0, 0, 53, 0 }, -{ 105, 0, 1, 1, 53, 0 }, -{ 105, 1, 2, 1, 1, 1 }, -{ 105, 2, 3, 1, 1, 1 }, -{ 105, 3, 4, 1, 1, 1 }, -{ 105, 4, 5, 1, 1, 1 }, -{ 105, 5, 6, 1, 1, 1 }, -{ 105, 6, 357, 51, 51, 51 }, -{ 105, 0, 358, 52, 51, 51 }, -{ 105, 1, 359, 52, 52, 52 }, -{ 105, 2, 360, 52, 52, 52 }, -{ 105, 3, 361, 52, 52, 52 }, -{ 105, 4, 362, 52, 52, 52 }, -{ 105, 5, 363, 52, 52, 52 }, -{ 105, 6, 364, 52, 52, 52 }, -{ 106, 0, 0, 1, 52, 0 }, -{ 106, 1, 1, 1, 1, 1 }, -{ 106, 2, 2, 1, 1, 1 }, -{ 106, 3, 3, 1, 1, 1 }, -{ 106, 4, 4, 1, 1, 1 }, -{ 106, 5, 5, 1, 1, 1 }, -{ 106, 6, 6, 1, 1, 1 }, -{ 106, 0, 357, 52, 51, 51 }, -{ 106, 1, 358, 52, 52, 52 }, -{ 106, 2, 359, 52, 52, 52 }, -{ 106, 3, 360, 52, 52, 52 }, -{ 106, 4, 361, 52, 52, 52 }, -{ 106, 5, 362, 52, 52, 52 }, -{ 106, 6, 363, 52, 52, 52 }, -{ 106, 0, 364, 53, 52, 52 }, -{ 107, 1, 0, 0, 1, 1 }, -{ 107, 2, 1, 0, 1, 1 }, -{ 107, 3, 2, 0, 1, 1 }, -{ 107, 4, 3, 0, 1, 1 }, -{ 107, 5, 4, 0, 1, 1 }, -{ 107, 6, 5, 0, 1, 1 }, -{ 107, 0, 6, 1, 1, 1 }, -{ 107, 1, 357, 51, 52, 52 }, -{ 107, 2, 358, 51, 52, 52 }, -{ 107, 3, 359, 51, 52, 52 }, -{ 107, 4, 360, 51, 52, 52 }, -{ 107, 5, 361, 51, 52, 52 }, -{ 107, 6, 362, 51, 52, 52 }, -{ 107, 0, 363, 52, 52, 52 }, -{ 107, 1, 364, 52, 1, 53 }, -{ 108, 2, 0, 0, 1, 0 }, -{ 108, 3, 1, 0, 1, 0 }, -{ 108, 4, 2, 0, 1, 0 }, -{ 108, 5, 3, 0, 1, 0 }, -{ 108, 6, 4, 0, 1, 0 }, -{ 108, 0, 5, 1, 1, 0 }, -{ 108, 1, 6, 1, 2, 1 }, -{ 108, 3, 358, 51, 52, 51 }, -{ 108, 4, 359, 51, 52, 51 }, -{ 108, 5, 360, 51, 52, 51 }, -{ 108, 6, 361, 51, 52, 51 }, -{ 108, 0, 362, 52, 52, 51 }, -{ 108, 1, 363, 52, 1, 52 }, -{ 108, 2, 364, 52, 1, 52 }, -{ 108, 3, 365, 52, 1, 52 }, -{ 109, 4, 0, 0, 1, 0 }, -{ 109, 5, 1, 0, 1, 0 }, -{ 109, 6, 2, 0, 1, 0 }, -{ 109, 0, 3, 1, 1, 0 }, -{ 109, 1, 4, 1, 2, 1 }, -{ 109, 2, 5, 1, 2, 1 }, -{ 109, 3, 6, 1, 2, 1 }, -{ 109, 4, 357, 51, 52, 51 }, -{ 109, 5, 358, 51, 52, 51 }, -{ 109, 6, 359, 51, 52, 51 }, -{ 109, 0, 360, 52, 52, 51 }, -{ 109, 1, 361, 52, 53, 52 }, -{ 109, 2, 362, 52, 53, 52 }, -{ 109, 3, 363, 52, 53, 52 }, -{ 109, 4, 364, 52, 53, 52 }, -{ 110, 5, 0, 0, 53, 0 }, -{ 110, 6, 1, 0, 53, 0 }, -{ 110, 0, 2, 1, 53, 0 }, -{ 110, 1, 3, 1, 1, 1 }, -{ 110, 2, 4, 1, 1, 1 }, -{ 110, 3, 5, 1, 1, 1 }, -{ 110, 4, 6, 1, 1, 1 }, -{ 110, 5, 357, 51, 51, 51 }, -{ 110, 6, 358, 51, 51, 51 }, -{ 110, 0, 359, 52, 51, 51 }, -{ 110, 1, 360, 52, 52, 52 }, -{ 110, 2, 361, 52, 52, 52 }, -{ 110, 3, 362, 52, 52, 52 }, -{ 110, 4, 363, 52, 52, 52 }, -{ 110, 5, 364, 52, 52, 52 }, -{ 111, 6, 0, 0, 52, 0 }, -{ 111, 0, 1, 1, 52, 0 }, -{ 111, 1, 2, 1, 1, 1 }, -{ 111, 2, 3, 1, 1, 1 }, -{ 111, 3, 4, 1, 1, 1 }, -{ 111, 4, 5, 1, 1, 1 }, -{ 111, 5, 6, 1, 1, 1 }, -{ 111, 6, 357, 51, 51, 51 }, -{ 111, 0, 358, 52, 51, 51 }, -{ 111, 1, 359, 52, 52, 52 }, -{ 111, 2, 360, 52, 52, 52 }, -{ 111, 3, 361, 52, 52, 52 }, -{ 111, 4, 362, 52, 52, 52 }, -{ 111, 5, 363, 52, 52, 52 }, -{ 111, 6, 364, 52, 52, 52 }, -{ 112, 0, 0, 1, 52, 0 }, -{ 112, 1, 1, 1, 1, 1 }, -{ 112, 2, 2, 1, 1, 1 }, -{ 112, 3, 3, 1, 1, 1 }, -{ 112, 4, 4, 1, 1, 1 }, -{ 112, 5, 5, 1, 1, 1 }, -{ 112, 6, 6, 1, 1, 1 }, -{ 112, 1, 358, 52, 52, 52 }, -{ 112, 2, 359, 52, 52, 52 }, -{ 112, 3, 360, 52, 52, 52 }, -{ 112, 4, 361, 52, 52, 52 }, -{ 112, 5, 362, 52, 52, 52 }, -{ 112, 6, 363, 52, 52, 52 }, -{ 112, 0, 364, 53, 52, 52 }, -{ 112, 1, 365, 53, 1, 53 }, -{ 113, 2, 0, 0, 1, 0 }, -{ 113, 3, 1, 0, 1, 0 }, -{ 113, 4, 2, 0, 1, 0 }, -{ 113, 5, 3, 0, 1, 0 }, -{ 113, 6, 4, 0, 1, 0 }, -{ 113, 0, 5, 1, 1, 0 }, -{ 113, 1, 6, 1, 2, 1 }, -{ 113, 2, 357, 51, 52, 51 }, -{ 113, 3, 358, 51, 52, 51 }, -{ 113, 4, 359, 51, 52, 51 }, -{ 113, 5, 360, 51, 52, 51 }, -{ 113, 6, 361, 51, 52, 51 }, -{ 113, 0, 362, 52, 52, 51 }, -{ 113, 1, 363, 52, 1, 52 }, -{ 113, 2, 364, 52, 1, 52 }, -{ 114, 3, 0, 0, 1, 0 }, -{ 114, 4, 1, 0, 1, 0 }, -{ 114, 5, 2, 0, 1, 0 }, -{ 114, 6, 3, 0, 1, 0 }, -{ 114, 0, 4, 1, 1, 0 }, -{ 114, 1, 5, 1, 2, 1 }, -{ 114, 2, 6, 1, 2, 1 }, -{ 114, 3, 357, 51, 52, 51 }, -{ 114, 4, 358, 51, 52, 51 }, -{ 114, 5, 359, 51, 52, 51 }, -{ 114, 6, 360, 51, 52, 51 }, -{ 114, 0, 361, 52, 52, 51 }, -{ 114, 1, 362, 52, 1, 52 }, -{ 114, 2, 363, 52, 1, 52 }, -{ 114, 3, 364, 52, 1, 52 }, -{ 115, 4, 0, 0, 1, 0 }, -{ 115, 5, 1, 0, 1, 0 }, -{ 115, 6, 2, 0, 1, 0 }, -{ 115, 0, 3, 1, 1, 0 }, -{ 115, 1, 4, 1, 2, 1 }, -{ 115, 2, 5, 1, 2, 1 }, -{ 115, 3, 6, 1, 2, 1 }, -{ 115, 4, 357, 51, 52, 51 }, -{ 115, 5, 358, 51, 52, 51 }, -{ 115, 6, 359, 51, 52, 51 }, -{ 115, 0, 360, 52, 52, 51 }, -{ 115, 1, 361, 52, 53, 52 }, -{ 115, 2, 362, 52, 53, 52 }, -{ 115, 3, 363, 52, 53, 52 }, -{ 115, 4, 364, 52, 53, 52 }, -{ 116, 5, 0, 0, 53, 0 }, -{ 116, 6, 1, 0, 53, 0 }, -{ 116, 0, 2, 1, 53, 0 }, -{ 116, 1, 3, 1, 1, 1 }, -{ 116, 2, 4, 1, 1, 1 }, -{ 116, 3, 5, 1, 1, 1 }, -{ 116, 4, 6, 1, 1, 1 }, -{ 116, 6, 358, 51, 51, 51 }, -{ 116, 0, 359, 52, 51, 51 }, -{ 116, 1, 360, 52, 52, 52 }, -{ 116, 2, 361, 52, 52, 52 }, -{ 116, 3, 362, 52, 52, 52 }, -{ 116, 4, 363, 52, 52, 52 }, -{ 116, 5, 364, 52, 52, 52 }, -{ 116, 6, 365, 52, 52, 52 }, -{ 117, 0, 0, 1, 52, 0 }, -{ 117, 1, 1, 1, 1, 1 }, -{ 117, 2, 2, 1, 1, 1 }, -{ 117, 3, 3, 1, 1, 1 }, -{ 117, 4, 4, 1, 1, 1 }, -{ 117, 5, 5, 1, 1, 1 }, -{ 117, 6, 6, 1, 1, 1 }, -{ 117, 0, 357, 52, 51, 51 }, -{ 117, 1, 358, 52, 52, 52 }, -{ 117, 2, 359, 52, 52, 52 }, -{ 117, 3, 360, 52, 52, 52 }, -{ 117, 4, 361, 52, 52, 52 }, -{ 117, 5, 362, 52, 52, 52 }, -{ 117, 6, 363, 52, 52, 52 }, -{ 117, 0, 364, 53, 52, 52 }, -{ 118, 1, 0, 0, 1, 1 }, -{ 118, 2, 1, 0, 1, 1 }, -{ 118, 3, 2, 0, 1, 1 }, -{ 118, 4, 3, 0, 1, 1 }, -{ 118, 5, 4, 0, 1, 1 }, -{ 118, 6, 5, 0, 1, 1 }, -{ 118, 0, 6, 1, 1, 1 }, -{ 118, 1, 357, 51, 52, 52 }, -{ 118, 2, 358, 51, 52, 52 }, -{ 118, 3, 359, 51, 52, 52 }, -{ 118, 4, 360, 51, 52, 52 }, -{ 118, 5, 361, 51, 52, 52 }, -{ 118, 6, 362, 51, 52, 52 }, -{ 118, 0, 363, 52, 52, 52 }, -{ 118, 1, 364, 52, 1, 53 }, -{ 119, 2, 0, 0, 1, 0 }, -{ 119, 3, 1, 0, 1, 0 }, -{ 119, 4, 2, 0, 1, 0 }, -{ 119, 5, 3, 0, 1, 0 }, -{ 119, 6, 4, 0, 1, 0 }, -{ 119, 0, 5, 1, 1, 0 }, -{ 119, 1, 6, 1, 2, 1 }, -{ 119, 2, 357, 51, 52, 51 }, -{ 119, 3, 358, 51, 52, 51 }, -{ 119, 4, 359, 51, 52, 51 }, -{ 119, 5, 360, 51, 52, 51 }, -{ 119, 6, 361, 51, 52, 51 }, -{ 119, 0, 362, 52, 52, 51 }, -{ 119, 1, 363, 52, 1, 52 }, -{ 119, 2, 364, 52, 1, 52 }, -{ 120, 3, 0, 0, 1, 0 }, -{ 120, 4, 1, 0, 1, 0 }, -{ 120, 5, 2, 0, 1, 0 }, -{ 120, 6, 3, 0, 1, 0 }, -{ 120, 0, 4, 1, 1, 0 }, -{ 120, 1, 5, 1, 2, 1 }, -{ 120, 2, 6, 1, 2, 1 }, -{ 120, 4, 358, 51, 52, 51 }, -{ 120, 5, 359, 51, 52, 51 }, -{ 120, 6, 360, 51, 52, 51 }, -{ 120, 0, 361, 52, 52, 51 }, -{ 120, 1, 362, 52, 53, 52 }, -{ 120, 2, 363, 52, 53, 52 }, -{ 120, 3, 364, 52, 53, 52 }, -{ 120, 4, 365, 52, 53, 52 }, -{ 121, 5, 0, 0, 53, 0 }, -{ 121, 6, 1, 0, 53, 0 }, -{ 121, 0, 2, 1, 53, 0 }, -{ 121, 1, 3, 1, 1, 1 }, -{ 121, 2, 4, 1, 1, 1 }, -{ 121, 3, 5, 1, 1, 1 }, -{ 121, 4, 6, 1, 1, 1 }, -{ 121, 5, 357, 51, 51, 51 }, -{ 121, 6, 358, 51, 51, 51 }, -{ 121, 0, 359, 52, 51, 51 }, -{ 121, 1, 360, 52, 52, 52 }, -{ 121, 2, 361, 52, 52, 52 }, -{ 121, 3, 362, 52, 52, 52 }, -{ 121, 4, 363, 52, 52, 52 }, -{ 121, 5, 364, 52, 52, 52 }, -{ 122, 6, 0, 0, 52, 0 }, -{ 122, 0, 1, 1, 52, 0 }, -{ 122, 1, 2, 1, 1, 1 }, -{ 122, 2, 3, 1, 1, 1 }, -{ 122, 3, 4, 1, 1, 1 }, -{ 122, 4, 5, 1, 1, 1 }, -{ 122, 5, 6, 1, 1, 1 }, -{ 122, 6, 357, 51, 51, 51 }, -{ 122, 0, 358, 52, 51, 51 }, -{ 122, 1, 359, 52, 52, 52 }, -{ 122, 2, 360, 52, 52, 52 }, -{ 122, 3, 361, 52, 52, 52 }, -{ 122, 4, 362, 52, 52, 52 }, -{ 122, 5, 363, 52, 52, 52 }, -{ 122, 6, 364, 52, 52, 52 }, -{ 123, 0, 0, 1, 52, 0 }, -{ 123, 1, 1, 1, 1, 1 }, -{ 123, 2, 2, 1, 1, 1 }, -{ 123, 3, 3, 1, 1, 1 }, -{ 123, 4, 4, 1, 1, 1 }, -{ 123, 5, 5, 1, 1, 1 }, -{ 123, 6, 6, 1, 1, 1 }, -{ 123, 0, 357, 52, 51, 51 }, -{ 123, 1, 358, 52, 52, 52 }, -{ 123, 2, 359, 52, 52, 52 }, -{ 123, 3, 360, 52, 52, 52 }, -{ 123, 4, 361, 52, 52, 52 }, -{ 123, 5, 362, 52, 52, 52 }, -{ 123, 6, 363, 52, 52, 52 }, -{ 123, 0, 364, 53, 52, 52 }, -{ 124, 1, 0, 0, 1, 1 }, -{ 124, 2, 1, 0, 1, 1 }, -{ 124, 3, 2, 0, 1, 1 }, -{ 124, 4, 3, 0, 1, 1 }, -{ 124, 5, 4, 0, 1, 1 }, -{ 124, 6, 5, 0, 1, 1 }, -{ 124, 0, 6, 1, 1, 1 }, -{ 124, 2, 358, 51, 52, 52 }, -{ 124, 3, 359, 51, 52, 52 }, -{ 124, 4, 360, 51, 52, 52 }, -{ 124, 5, 361, 51, 52, 52 }, -{ 124, 6, 362, 51, 52, 52 }, -{ 124, 0, 363, 52, 52, 52 }, -{ 124, 1, 364, 52, 1, 53 }, -{ 124, 2, 365, 52, 1, 53 }, -{ 125, 3, 0, 0, 1, 0 }, -{ 125, 4, 1, 0, 1, 0 }, -{ 125, 5, 2, 0, 1, 0 }, -{ 125, 6, 3, 0, 1, 0 }, -{ 125, 0, 4, 1, 1, 0 }, -{ 125, 1, 5, 1, 2, 1 }, -{ 125, 2, 6, 1, 2, 1 }, -{ 125, 3, 357, 51, 52, 51 }, -{ 125, 4, 358, 51, 52, 51 }, -{ 125, 5, 359, 51, 52, 51 }, -{ 125, 6, 360, 51, 52, 51 }, -{ 125, 0, 361, 52, 52, 51 }, -{ 125, 1, 362, 52, 1, 52 }, -{ 125, 2, 363, 52, 1, 52 }, -{ 125, 3, 364, 52, 1, 52 }, -{ 126, 4, 0, 0, 1, 0 }, -{ 126, 5, 1, 0, 1, 0 }, -{ 126, 6, 2, 0, 1, 0 }, -{ 126, 0, 3, 1, 1, 0 }, -{ 126, 1, 4, 1, 2, 1 }, -{ 126, 2, 5, 1, 2, 1 }, -{ 126, 3, 6, 1, 2, 1 }, -{ 126, 4, 357, 51, 52, 51 }, -{ 126, 5, 358, 51, 52, 51 }, -{ 126, 6, 359, 51, 52, 51 }, -{ 126, 0, 360, 52, 52, 51 }, -{ 126, 1, 361, 52, 53, 52 }, -{ 126, 2, 362, 52, 53, 52 }, -{ 126, 3, 363, 52, 53, 52 }, -{ 126, 4, 364, 52, 53, 52 }, -{ 127, 5, 0, 0, 53, 0 }, -{ 127, 6, 1, 0, 53, 0 }, -{ 127, 0, 2, 1, 53, 0 }, -{ 127, 1, 3, 1, 1, 1 }, -{ 127, 2, 4, 1, 1, 1 }, -{ 127, 3, 5, 1, 1, 1 }, -{ 127, 4, 6, 1, 1, 1 }, -{ 127, 5, 357, 51, 51, 51 }, -{ 127, 6, 358, 51, 51, 51 }, -{ 127, 0, 359, 52, 51, 51 }, -{ 127, 1, 360, 52, 52, 52 }, -{ 127, 2, 361, 52, 52, 52 }, -{ 127, 3, 362, 52, 52, 52 }, -{ 127, 4, 363, 52, 52, 52 }, -{ 127, 5, 364, 52, 52, 52 }, -{ 128, 6, 0, 0, 52, 0 }, -{ 128, 0, 1, 1, 52, 0 }, -{ 128, 1, 2, 1, 1, 1 }, -{ 128, 2, 3, 1, 1, 1 }, -{ 128, 3, 4, 1, 1, 1 }, -{ 128, 4, 5, 1, 1, 1 }, -{ 128, 5, 6, 1, 1, 1 }, -{ 128, 0, 358, 52, 51, 51 }, -{ 128, 1, 359, 52, 52, 52 }, -{ 128, 2, 360, 52, 52, 52 }, -{ 128, 3, 361, 52, 52, 52 }, -{ 128, 4, 362, 52, 52, 52 }, -{ 128, 5, 363, 52, 52, 52 }, -{ 128, 6, 364, 52, 52, 52 }, -{ 128, 0, 365, 53, 52, 52 }, -{ 129, 1, 0, 0, 1, 1 }, -{ 129, 2, 1, 0, 1, 1 }, -{ 129, 3, 2, 0, 1, 1 }, -{ 129, 4, 3, 0, 1, 1 }, -{ 129, 5, 4, 0, 1, 1 }, -{ 129, 6, 5, 0, 1, 1 }, -{ 129, 0, 6, 1, 1, 1 }, -{ 129, 1, 357, 51, 52, 52 }, -{ 129, 2, 358, 51, 52, 52 }, -{ 129, 3, 359, 51, 52, 52 }, -{ 129, 4, 360, 51, 52, 52 }, -{ 129, 5, 361, 51, 52, 52 }, -{ 129, 6, 362, 51, 52, 52 }, -{ 129, 0, 363, 52, 52, 52 }, -{ 129, 1, 364, 52, 1, 53 }, -{ 130, 2, 0, 0, 1, 0 }, -{ 130, 3, 1, 0, 1, 0 }, -{ 130, 4, 2, 0, 1, 0 }, -{ 130, 5, 3, 0, 1, 0 }, -{ 130, 6, 4, 0, 1, 0 }, -{ 130, 0, 5, 1, 1, 0 }, -{ 130, 1, 6, 1, 2, 1 }, -{ 130, 2, 357, 51, 52, 51 }, -{ 130, 3, 358, 51, 52, 51 }, -{ 130, 4, 359, 51, 52, 51 }, -{ 130, 5, 360, 51, 52, 51 }, -{ 130, 6, 361, 51, 52, 51 }, -{ 130, 0, 362, 52, 52, 51 }, -{ 130, 1, 363, 52, 1, 52 }, -{ 130, 2, 364, 52, 1, 52 }, -{ 131, 3, 0, 0, 1, 0 }, -{ 131, 4, 1, 0, 1, 0 }, -{ 131, 5, 2, 0, 1, 0 }, -{ 131, 6, 3, 0, 1, 0 }, -{ 131, 0, 4, 1, 1, 0 }, -{ 131, 1, 5, 1, 2, 1 }, -{ 131, 2, 6, 1, 2, 1 }, -{ 131, 3, 357, 51, 52, 51 }, -{ 131, 4, 358, 51, 52, 51 }, -{ 131, 5, 359, 51, 52, 51 }, -{ 131, 6, 360, 51, 52, 51 }, -{ 131, 0, 361, 52, 52, 51 }, -{ 131, 1, 362, 52, 1, 52 }, -{ 131, 2, 363, 52, 1, 52 }, -{ 131, 3, 364, 52, 1, 52 }, -{ 132, 4, 0, 0, 1, 0 }, -{ 132, 5, 1, 0, 1, 0 }, -{ 132, 6, 2, 0, 1, 0 }, -{ 132, 0, 3, 1, 1, 0 }, -{ 132, 1, 4, 1, 2, 1 }, -{ 132, 2, 5, 1, 2, 1 }, -{ 132, 3, 6, 1, 2, 1 }, -{ 132, 5, 358, 51, 52, 51 }, -{ 132, 6, 359, 51, 52, 51 }, -{ 132, 0, 360, 52, 52, 51 }, -{ 132, 1, 361, 52, 53, 52 }, -{ 132, 2, 362, 52, 53, 52 }, -{ 132, 3, 363, 52, 53, 52 }, -{ 132, 4, 364, 52, 53, 52 }, -{ 132, 5, 365, 52, 53, 52 }, -{ 133, 6, 0, 0, 53, 0 }, -{ 133, 0, 1, 1, 53, 0 }, -{ 133, 1, 2, 1, 1, 1 }, -{ 133, 2, 3, 1, 1, 1 }, -{ 133, 3, 4, 1, 1, 1 }, -{ 133, 4, 5, 1, 1, 1 }, -{ 133, 5, 6, 1, 1, 1 }, -{ 133, 6, 357, 51, 51, 51 }, -{ 133, 0, 358, 52, 51, 51 }, -{ 133, 1, 359, 52, 52, 52 }, -{ 133, 2, 360, 52, 52, 52 }, -{ 133, 3, 361, 52, 52, 52 }, -{ 133, 4, 362, 52, 52, 52 }, -{ 133, 5, 363, 52, 52, 52 }, -{ 133, 6, 364, 52, 52, 52 }, -{ 134, 0, 0, 1, 52, 0 }, -{ 134, 1, 1, 1, 1, 1 }, -{ 134, 2, 2, 1, 1, 1 }, -{ 134, 3, 3, 1, 1, 1 }, -{ 134, 4, 4, 1, 1, 1 }, -{ 134, 5, 5, 1, 1, 1 }, -{ 134, 6, 6, 1, 1, 1 }, -{ 134, 0, 357, 52, 51, 51 }, -{ 134, 1, 358, 52, 52, 52 }, -{ 134, 2, 359, 52, 52, 52 }, -{ 134, 3, 360, 52, 52, 52 }, -{ 134, 4, 361, 52, 52, 52 }, -{ 134, 5, 362, 52, 52, 52 }, -{ 134, 6, 363, 52, 52, 52 }, -{ 134, 0, 364, 53, 52, 52 }, -{ 135, 1, 0, 0, 1, 1 }, -{ 135, 2, 1, 0, 1, 1 }, -{ 135, 3, 2, 0, 1, 1 }, -{ 135, 4, 3, 0, 1, 1 }, -{ 135, 5, 4, 0, 1, 1 }, -{ 135, 6, 5, 0, 1, 1 }, -{ 135, 0, 6, 1, 1, 1 }, -{ 135, 1, 357, 51, 52, 52 }, -{ 135, 2, 358, 51, 52, 52 }, -{ 135, 3, 359, 51, 52, 52 }, -{ 135, 4, 360, 51, 52, 52 }, -{ 135, 5, 361, 51, 52, 52 }, -{ 135, 6, 362, 51, 52, 52 }, -{ 135, 0, 363, 52, 52, 52 }, -{ 135, 1, 364, 52, 1, 53 }, -{ 136, 2, 0, 0, 1, 0 }, -{ 136, 3, 1, 0, 1, 0 }, -{ 136, 4, 2, 0, 1, 0 }, -{ 136, 5, 3, 0, 1, 0 }, -{ 136, 6, 4, 0, 1, 0 }, -{ 136, 0, 5, 1, 1, 0 }, -{ 136, 1, 6, 1, 2, 1 }, -{ 136, 3, 358, 51, 52, 51 }, -{ 136, 4, 359, 51, 52, 51 }, -{ 136, 5, 360, 51, 52, 51 }, -{ 136, 6, 361, 51, 52, 51 }, -{ 136, 0, 362, 52, 52, 51 }, -{ 136, 1, 363, 52, 1, 52 }, -{ 136, 2, 364, 52, 1, 52 }, -{ 136, 3, 365, 52, 1, 52 }, -{ 137, 4, 0, 0, 1, 0 }, -{ 137, 5, 1, 0, 1, 0 }, -{ 137, 6, 2, 0, 1, 0 }, -{ 137, 0, 3, 1, 1, 0 }, -{ 137, 1, 4, 1, 2, 1 }, -{ 137, 2, 5, 1, 2, 1 }, -{ 137, 3, 6, 1, 2, 1 }, -{ 137, 4, 357, 51, 52, 51 }, -{ 137, 5, 358, 51, 52, 51 }, -{ 137, 6, 359, 51, 52, 51 }, -{ 137, 0, 360, 52, 52, 51 }, -{ 137, 1, 361, 52, 53, 52 }, -{ 137, 2, 362, 52, 53, 52 }, -{ 137, 3, 363, 52, 53, 52 }, -{ 137, 4, 364, 52, 53, 52 }, -}; - -static int test_week_calc( void ) -{ - char buffer[100]; - int rc = 1; - int i; - for ( i = 0; i < 1020; ++i ) - { - struct tm t; - int U, V, W; - t.tm_year = data[i][0]; - t.tm_wday = data[i][1]; - t.tm_yday = data[i][2]; - assert( strftime( buffer, 100, "%U %V %W", &t ) == 8 ); - assert( sscanf( buffer, "%d %d %d", &U, &V, &W ) == 3 ); - if ( data[i][3] != U || data[i][4] != V || data[i][5] != W ) - { - printf( "Fehler in { %d, %d, %d, %d, %d, %d } (encountered { %d, %d, %d })\n", data[i][0], data[i][1], data[i][2], data[i][3], data[i][4], data[i][5], U, V, W ); - rc = 0; - } - } - return rc; -} - -START_TEST( strftime ) -{ - char buffer[100]; - /* Basic functionality */ - struct tm timeptr; - MKTIME( timeptr, 59, 30, 12, 1, 9, 72, 0, 274 ); - - TESTCASE( - (strftime(buffer, 100, "%a ", &timeptr) == 4) && - (strcmp(buffer, "Sun ") == 0) ); - TESTCASE( - (strftime(buffer, 100, "%A ", &timeptr) == 7) && - (strcmp(buffer, "Sunday ") == 0) ); - TESTCASE( - (strftime(buffer, 100, "%b ", &timeptr) == 4) && - (strcmp(buffer, "Oct ") == 0) ); - TESTCASE( - (strftime(buffer, 100, "%h ", &timeptr) == 4) && - (strcmp(buffer, "Oct ") == 0) ); - TESTCASE( - (strftime(buffer, 100, "%B ", &timeptr) == 8) && - (strcmp(buffer, "October ") == 0) ); - TESTCASE( - (strftime(buffer, 100, "%c ", &timeptr) == 25) && - (strcmp(buffer, "Sun Oct 1 12:30:59 1972 ") == 0) ); - TESTCASE( - (strftime(buffer, 100, "%C ", &timeptr) == 3) && - (strcmp(buffer, "19 ") == 0) ); - TESTCASE( - (strftime(buffer, 100, "%d ", &timeptr) == 3) && - (strcmp(buffer, "01 ") == 0) ); - TESTCASE( - (strftime(buffer, 100, "%D ", &timeptr) == 9) && - (strcmp(buffer, "10/01/72 ") == 0) ); - TESTCASE( - (strftime(buffer, 100, "%e ", &timeptr) == 3) && - (strcmp(buffer, " 1 ") == 0) ); - TESTCASE( - (strftime(buffer, 100, "%F ", &timeptr) == 11) && - (strcmp(buffer, "1972-10-01 ") == 0) ); - TESTCASE( - (strftime(buffer, 100, "%H ", &timeptr) == 3) && - (strcmp(buffer, "12 ") == 0) ); - TESTCASE( - (strftime(buffer, 100, "%I ", &timeptr) == 3) && - (strcmp(buffer, "12 ") == 0) ); - TESTCASE( - (strftime(buffer, 100, "%j ", &timeptr) == 4) && - (strcmp(buffer, "275 ") == 0) ); - TESTCASE( - (strftime(buffer, 100, "%m ", &timeptr) == 3) && - (strcmp(buffer, "10 ") == 0) ); - TESTCASE( - (strftime(buffer, 100, "%M ", &timeptr) == 3) && - (strcmp(buffer, "30 ") == 0) ); - TESTCASE( - (strftime(buffer, 100, "%p ", &timeptr) == 3) && - (strcmp(buffer, "PM ") == 0) ); - TESTCASE( - (strftime(buffer, 100, "%r ", &timeptr) == 12) && - (strcmp(buffer, "12:30:59 PM ") == 0) ); - TESTCASE( - (strftime(buffer, 100, "%R ", &timeptr) == 6) && - (strcmp(buffer, "12:30 ") == 0) ); - TESTCASE( - (strftime(buffer, 100, "%S ", &timeptr) == 3) && - (strcmp(buffer, "59 ") == 0) ); - TESTCASE( - (strftime(buffer, 100, "%T ", &timeptr) == 9) && - (strcmp(buffer, "12:30:59 ") == 0) ); - TESTCASE( - (strftime(buffer, 100, "%u ", &timeptr) == 2) && - (strcmp(buffer, "7 ") == 0) ); - TESTCASE( - (strftime(buffer, 100, "%w ", &timeptr) == 2) && - (strcmp(buffer, "0 ") == 0) ); - TESTCASE( - (strftime(buffer, 100, "%x ", &timeptr) == 9) && - (strcmp(buffer, "10/01/72 ") == 0) ); - TESTCASE( - (strftime(buffer, 100, "%X ", &timeptr) == 9) && - (strcmp(buffer, "12:30:59 ") == 0) ); - TESTCASE( - (strftime(buffer, 100, "%y ", &timeptr) == 3) && - (strcmp(buffer, "72 ") == 0) ); - TESTCASE( - (strftime(buffer, 100, "%Y ", &timeptr) == 5) && - (strcmp(buffer, "1972 ") == 0) ); - TESTCASE( - (strftime(buffer, 100, "%% ", &timeptr) == 2) && - (strcmp(buffer, "% ") == 0) ); - TESTCASE( - (strftime(buffer, 100, "%n ", &timeptr) == 2) && - (strcmp(buffer, "\n ") == 0) ); - TESTCASE( - (strftime(buffer, 100, "%t ", &timeptr) == 2) && - (strcmp(buffer, "\t ") == 0) ); - - TESTCASE( test_week_calc() ); -} -END_TEST - -START_SUITE( time ) -{ - RUN_TEST( strftime ); -} -END_SUITE diff --git a/src/libraries/libc/tests/testfile.txt b/src/libraries/libc/tests/testfile.txt deleted file mode 100644 index f08c4d3..0000000 Binary files a/src/libraries/libc/tests/testfile.txt and /dev/null differ diff --git a/src/libraries/libc/include/time.h b/src/libraries/libc/time.h similarity index 100% rename from src/libraries/libc/include/time.h rename to src/libraries/libc/time.h diff --git a/src/libraries/libc/include/wchar.h b/src/libraries/libc/wchar.h similarity index 100% rename from src/libraries/libc/include/wchar.h rename to src/libraries/libc/wchar.h diff --git a/src/libraries/libc/include/wctype.h b/src/libraries/libc/wctype.h similarity index 100% rename from src/libraries/libc/include/wctype.h rename to src/libraries/libc/wctype.h diff --git a/src/libraries/util/util.module b/src/libraries/util/util.module index 3979ff6..b8009e6 100644 --- a/src/libraries/util/util.module +++ b/src/libraries/util/util.module @@ -2,8 +2,24 @@ module("util", kind = "lib", - includes = [ "include" ], sources = [ "bip_buffer.cpp", "spinlock.cpp", + ], + public_headers = [ + "util/basic_types.h", + "util/bip_buffer.h", + "util/constexpr_hash.h", + "util/counted.h", + "util/deque.h", + "util/enum_bitfields.h", + "util/hash.h", + "util/linked_list.h", + "util/map.h", + "util/misc.h", + "util/no_construct.h", + "util/pointers.h", + "util/spinlock.h", + "util/util.h", + "util/vector.h", ]) diff --git a/src/libraries/util/include/util/basic_types.h b/src/libraries/util/util/basic_types.h similarity index 100% rename from src/libraries/util/include/util/basic_types.h rename to src/libraries/util/util/basic_types.h diff --git a/src/libraries/util/include/util/bip_buffer.h b/src/libraries/util/util/bip_buffer.h similarity index 100% rename from src/libraries/util/include/util/bip_buffer.h rename to src/libraries/util/util/bip_buffer.h diff --git a/src/libraries/util/include/util/constexpr_hash.h b/src/libraries/util/util/constexpr_hash.h similarity index 100% rename from src/libraries/util/include/util/constexpr_hash.h rename to src/libraries/util/util/constexpr_hash.h diff --git a/src/libraries/util/include/util/counted.h b/src/libraries/util/util/counted.h similarity index 100% rename from src/libraries/util/include/util/counted.h rename to src/libraries/util/util/counted.h diff --git a/src/libraries/util/include/util/deque.h b/src/libraries/util/util/deque.h similarity index 100% rename from src/libraries/util/include/util/deque.h rename to src/libraries/util/util/deque.h diff --git a/src/libraries/util/include/util/enum_bitfields.h b/src/libraries/util/util/enum_bitfields.h similarity index 100% rename from src/libraries/util/include/util/enum_bitfields.h rename to src/libraries/util/util/enum_bitfields.h diff --git a/src/libraries/util/include/util/hash.h b/src/libraries/util/util/hash.h similarity index 100% rename from src/libraries/util/include/util/hash.h rename to src/libraries/util/util/hash.h diff --git a/src/libraries/util/include/util/linked_list.h b/src/libraries/util/util/linked_list.h similarity index 100% rename from src/libraries/util/include/util/linked_list.h rename to src/libraries/util/util/linked_list.h diff --git a/src/libraries/util/include/util/map.h b/src/libraries/util/util/map.h similarity index 100% rename from src/libraries/util/include/util/map.h rename to src/libraries/util/util/map.h diff --git a/src/libraries/util/include/util/misc.h b/src/libraries/util/util/misc.h similarity index 100% rename from src/libraries/util/include/util/misc.h rename to src/libraries/util/util/misc.h diff --git a/src/libraries/util/include/util/no_construct.h b/src/libraries/util/util/no_construct.h similarity index 100% rename from src/libraries/util/include/util/no_construct.h rename to src/libraries/util/util/no_construct.h diff --git a/src/libraries/util/include/util/pointers.h b/src/libraries/util/util/pointers.h similarity index 100% rename from src/libraries/util/include/util/pointers.h rename to src/libraries/util/util/pointers.h diff --git a/src/libraries/util/include/util/spinlock.h b/src/libraries/util/util/spinlock.h similarity index 100% rename from src/libraries/util/include/util/spinlock.h rename to src/libraries/util/util/spinlock.h diff --git a/src/libraries/util/include/util/util.h b/src/libraries/util/util/util.h similarity index 100% rename from src/libraries/util/include/util/util.h rename to src/libraries/util/util/util.h diff --git a/src/libraries/util/include/util/vector.h b/src/libraries/util/util/vector.h similarity index 100% rename from src/libraries/util/include/util/vector.h rename to src/libraries/util/util/vector.h