Repository: paulo-santana/ft_printf_tester Branch: master Commit: a053a3500c91 Files: 35 Total size: 185.6 KB Directory structure: gitextract_p4qcftn9/ ├── .gitignore ├── .gitmodules ├── Makefile ├── README.md ├── libtest/ │ ├── .gitignore │ ├── Makefile │ ├── diff.c │ ├── libtest.h │ ├── print_errors.c │ └── string.c ├── malloc_count-0.7/ │ ├── README.md │ ├── memprofile.h │ ├── stack_count.c │ ├── stack_count.h │ ├── test-malloc_count/ │ │ ├── Makefile │ │ └── test.c │ └── test-memprofile/ │ ├── Makefile │ ├── memprofile.gnuplot │ └── test.cc ├── obj/ │ └── .gitignore ├── src/ │ ├── .gitignore │ ├── ft_printf_tester.h │ ├── get_next_line.c │ ├── get_next_line.h │ ├── get_next_line_utils.c │ ├── helpers.h │ ├── libftprintf.h │ ├── malloc_count.c │ ├── malloc_count.h │ ├── system_printer.c │ ├── tests.c │ ├── tests.c.old │ ├── user_printer.c │ └── utils.c └── test ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ *.o vgcore* tester files tester.dSYM myleaks.txt compile_commands.json .cache/ main.c ================================================ FILE: .gitmodules ================================================ [submodule "get_next_line"] path = get_next_line url = https://github.com/paulo-santana/get_next_line ================================================ FILE: Makefile ================================================ LIBFTPRINTF_DIR = ../ ERROR_LIMIT = 0 SHELL = /bin/sh # I'm not proud of this TESTS = $(shell for ((i=1;i<=2000;i++)); do echo "$$i "; done) NAME = tester LIBTEST = libtest/libtest.a LIBFTPRINTF = ${LIBFTPRINTF_DIR}/libftprintf.a SRC_DIR = ./src OBJ_DIR = ./obj SRCS_FILES = main.c \ tests.c \ get_next_line.c \ get_next_line_utils.c \ utils.c HEADERS_FILES = helpers.h HEADERS = ${addprefix ${SRC_DIR}/, ${HEADERS_FILES}} SRCS = ${addprefix ${SRC_DIR}/, ${SRCS_FILES}} OBJS_FILES = ${SRCS_FILES:.c=.o} OBJS = ${addprefix ${OBJ_DIR}/, ${OBJS_FILES}} CFLAGS = -Wall -Wextra -g3 PRINTF_FLAGS = ${CFLAGS} -Werror SANITIZE = -fsanitize=address UNAME = ${shell uname -s} ifeq (${UNAME}, Darwin) SRCS_FILES := ${SRCS_FILES} malloc_count.c endif CC = clang ${CFLAGS} export LSAN_OPTIONS=exitcode=30 all: ${NAME} @echo "" nosan: SANITIZE := nosan: ${NAME} @echo "" ${NAME}: ${LIBFTPRINTF} ${LIBTEST} ${HEADERS} ${OBJS} ${CC} ${SANITIZE} -L./libtest -L${LIBFTPRINTF_DIR} ${OBJS} -o ${NAME} -ltest -lftprintf -ldl mkdir -p files ${LIBFTPRINTF}: make -C ${LIBFTPRINTF_DIR} ${LIBTEST}: make -C libtest CFLAGS="${CFLAGS}" ${OBJ_DIR}/%.o: ${SRC_DIR}/%.c ${HEADERS} Makefile ${CC} -DERROR_LIMIT=${ERROR_LIMIT} -DBUFFER_SIZE=32 -c $< -o $@ r: run run: ./${NAME} 2>myleaks.txt ${TESTS}: SANITIZE := -fsanitize=address ${TESTS}: ${NAME} ./${NAME} $@ 2>myle _bonus: make CFLAGS="${PRINTF_FLAGS}" -C ${LIBFTPRINTF_DIR} bonus bonus: _bonus ${NAME} bonusnosan: SANITIZE := bonusnosan: _bonus ${NAME} push: git add -A git commit -m "chore: automated commit" git push clean: @echo cleaning... @make -C ./libtest clean make -C ${LIBFTPRINTF_DIR} clean @${RM} ${OBJS} fclean: clean @make -C ./libtest fclean make -C ${LIBFTPRINTF_DIR} fclean @${RM} ${NAME} re: fclean all .PHONY: ${NAME} ${LIBTEST} ${LIBFTPRINTF} ================================================ FILE: README.md ================================================ # ft_printf tester A tester for 42's **ft_printf** project. ## Disclaimer and an advice Try to not use these tests (or any other tests you didn't code yourself) to develop your project. **Write your own tests instead***. Since the C01 piscine list, 42 expects us to use more time writing test code than actual project code. And this comes with a bunch of somewhat "invisible" benefits, and if you don't practice it you won't notice you're losing them. To get better at programming, you need to practice. But the more tests written by other persons you use, the less tests you'll write yourself. Writing fewer tests means writing less code overall. And blindly following tests you didn't write means you won't be exercising creativity and could probably squeeze even more your tunnel vision. And these tests might even be wrong or incomplete. This whole project started as a "side job" when I was doing my printf. It was actually funnier to work on it and I learned A LOT about processes, signals, forks and pipes. These concepts are the basis of the minishell project. There's no need for you to go this deep if you're a newbee in programming or just don't have enough time, but you shouldn't be neglecting the benefits of writing more code and learning new stuff. Do yourself a favor and write your own tests. #### Why this? After some intense arguments, I realised this tester could be harmful for people that misuse it, as it is an automation of a huge part of what is expected by the project (for you to write a big load of tests). I could just destroy this repository and go on my way, but I know it won't stop people from using it, there are backups everywhere, and I would just be erasing a cool project from my github profile. So instead I'll leave these advices here, it's up to you to follow them or not. I would recommend using testers only after being KOed by the moulinette. ----------------- It runs a series of tests against `ft_printf()` and compares the output with the original `printf()`. It works on both linux and mac. On linux and macos the output differs. If a test detects that the output is wrong, it will print information about what should've been printed. It compiles the program with the AddressSanitizer flag, mainly to detect memory leaks and invalid access. However, it makes the tests run slowly. The option `nosan` disables the compilation with the address sanitizer, so the tests can run faster. Because the ASAN's LeakSanitizer doesn't work on Mac, this tester checks for memory leaks using a library called `malloc_count` if running on Darwin. If you find any problems, please [open an issue](https://github.com/paulo-santana/ft_printf_tester/issues/new) ### RTFM Clone the test repository inside the folder where you generate the `libftprintf.a` file, then `cd` into it. The tests are managed maily by a shell script. Here are some command examples: * `sh test`: run all the tests * `sh test m`: run all the mandatory tests * `sh test b1`: run the first bonus tests (`'-0.'` and widths) * `sh test b2`: run the second bonus tests (`'# +'`) * `sh test d`: run only the `mandatory` tests related to the `%d` specifier. Currently, only the `cspdiuxX%` specifiers are supported * `sh test b1 c`: run the `b1` tests related to the `%c` specifier. * `sh test b2 X`: run the `b2` tests related to the `%X` specifier. * `sh test b1 b2`: run all the bonus tests * `sh test nosan`: run all the tests without the AddressSanitizer * `sh test nosan m`: run all the mandatory tests without the AddressSanitizer * `sh test nosan b1`: run the first bonus tests without the AddressSanitizer * `sh test nosan p`: run all tests related to the `%p` without the AddressSanitizer * `sh test 1088`: run only the 1088th test ### Limiting errors output If there are so many errors that you can't even see the whole output, you can limit the error tolerance by changing the `ERROR_LIMIT` variable in the Makefile. By default, it is set to 0, which means no limit. You can also pipe the output to `less`: `sh test | less -r` ### TODO: - [x] Print useful information in case of errors - [x] print the diff between `printf` and `ft_printf` - [x] print the function that was called on that specific test - [x] give information about when the returned value was wrong ================================================ FILE: libtest/.gitignore ================================================ libtest.a *.o ================================================ FILE: libtest/Makefile ================================================ NAME = libtest.a SRCS = string.c \ print_errors.c \ diff.c OBJS = ${SRCS:.c=.o} AR = ar rcs CFLAGS = -Wall -Werror -Wextra CC = clang ${CFLAGS} all: ${NAME} ${NAME}: ${OBJS} ${AR} ${NAME} ${OBJS} %.o: %.c ${CC} -c $< -o $@ clean: ${RM} ${OBJS} fclean: clean ${RM} ${NAME} re: fclean all ================================================ FILE: libtest/diff.c ================================================ #include "libtest.h" int test_string(char *expected, char *got, int limit) { int success = 1; if (expected == NULL) { if (got != NULL) success = 0; } else if (got == NULL) success = 0; else if (memcmp(expected, got, limit) != 0) success = 0; return (success); } ================================================ FILE: libtest/libtest.h ================================================ #ifndef LIBTEST_H # define LIBTEST_H # include # include # include # include # include # include # define BOLD "\x1b[1m" # define RED "\x1b[31m" # define GREEN "\x1b[32m" # define YELLOW "\x1b[33m" # define BLUE "\x1b[34m" # define MAGENTA "\x1b[35m" # define CYAN "\x1b[36m" # define RESET "\x1b[0m" size_t tester_strlen(const char *str); void tester_putchar(char c); void tester_putstr(char *str); void tester_putnbr(int nbr); char *tester_strnstr(const char *big, const char *little, size_t len); void print_int_diff(int expected, int result); void print_string_diff(char expected[], char result[], unsigned int expected_size, unsigned int result_size); int test_string(char *expected, char *got, int limit); int test_int(char *description, int expected, int result); void print_success(char *desc, int success); void print_non_print(char c); #endif ================================================ FILE: libtest/print_errors.c ================================================ #include "libtest.h" void print_int_diff(int expected, int result) { tester_putstr(" Expected: "); tester_putnbr(expected); tester_putstr("\n Got : " RED); tester_putnbr(result); tester_putstr(RESET "\n"); } void print_non_print(char c) { char cx[3]; int size = 0; char *hexmap = "0123456789abcdef"; if (c == '\n') { cx[0] = '\\'; cx[1] = 'n'; size = 2; } else if (c >= 16) { cx[0] = '\\'; cx[1] = hexmap[c / 16]; cx[2] = hexmap[c % 16]; size = 3; } else { cx[0] = '\\'; cx[1] = hexmap[c % 16]; size = 2; } tester_putstr(MAGENTA); write(1, cx, size); tester_putstr(RESET); } ================================================ FILE: libtest/string.c ================================================ #include "libtest.h" size_t tester_strlen(const char *str) { size_t len; len = 0; while (*str++) len++; return (len); } static int str_matches(char *str, const char *target) { int matches; int to_find_pos; matches = 0; to_find_pos = 0; while (target[to_find_pos] != '\0') { if (target[to_find_pos] != str[to_find_pos]) { matches = 0; to_find_pos++; break ; } else { matches = 1; to_find_pos++; } } return (matches); } char *tester_strnstr(const char *big, const char *little, size_t len) { size_t i; size_t limit; int matches; int little_len; char *match_start; i = 0; matches = 0; little_len = tester_strlen((char *)little); if (little_len == 0) return ((char *)big); if (len == 0) return (NULL); limit = len - little_len; while (i <= limit) { if (big[i] == 0) break ; match_start = (char *)&big[i]; matches = str_matches(match_start, little); if (matches) return (match_start); i++; } return (0); } void tester_putchar(char c) { write(1, &c, 1); } void tester_putstr(char *str) { size_t len = strlen(str); write(1, str, len); } void tester_putnbr(int nbr) { long number; char digit; number = nbr; if (number < 0) { write(1, "-", 1); number *= -1; } if (number > 9) { tester_putnbr(number / 10); tester_putnbr(number % 10); } else { digit = number + '0'; write(1, &digit, 1); } } ================================================ FILE: malloc_count-0.7/README.md ================================================ # README for malloc_count # `malloc_count` provides a set of source code tools to **measure the amount of allocated memory of a program at run-time**. The code library provides facilities to * measure the **current and peak** heap memory allocation, and * write a **memory profile** for plotting, see the figure on the right. * Furthermore, separate `stack_count` function can measure **stack usage**. The code tool works by intercepting the standard `malloc()`, `free()`, etc functions. Thus **no changes** are necessary to the inspected source code. See for the current verison. ## Intercepting Heap Allocation Functions ## The source code of `malloc_count.[ch]` intercepts the standard heap allocation functions `malloc()`, `free()`, `realloc()` and `calloc()` and adds simple counting statistics to each call. Thus the program must be relinked for `malloc_count` to work. Each call to `malloc()` and others is passed on to lower levels, and the regular `malloc()` is used for heap allocation. Of course, `malloc_count` can also be used with C++ programs and maybe even script languages, because the `new` operator and script interpreter allocations all are based on `malloc`. The tools are usable under Linux and probably also with Cygwin and MinGW, as they too support the standard Linux dynamic link loading mechanisms. ## Memory Profile and `stack_count` The `malloc_count` source is accompanied by two further memory analysis tools: `stack_count` and a C++ header called `memprofile.h`. In `stack_count.[ch]` two simple functions are provided that can measure the **maximum stack usage** between two points in a program. Maybe the most useful application of `malloc_count` is to create a **memory/heap profile** of a program (while it is running). This profile can also be created using the well-known [valgrind tool "massif"](http://valgrind.org/docs/manual/ms-manual.html), however, massif is really slow. The overhead of `malloc_count` is much smaller, and using `memprofile.h` a statistic file can be produced, which is directly usable with Gnuplot. The source code archive contains two example applications: one which queries `malloc_count` for current heap usage, and a second which creates the memory profile in the figure on the right. See the STX B+ Tree library for another, more complex example of a memory profile. ## Downloads ## See for the current verison. The source code is published under the [MIT License (MIT)](http://opensource.org/licenses/MIT), which is also found in the header of all source files. ## Short Usage Guide ## Compile `malloc_count.c` and link it with your program. The source file `malloc_count.o` should be located towards the end of the `.o` file sequence. You must also add "`-ldl`" to the list of libraries. Run your program and observe that when terminating, it outputs a line like malloc_count ### exiting, total: 12,582,912, peak: 4,194,304, current: 0 If desired, increase verbosity 1. by setting `log_operations = 1` at the top of `malloc_count.c` and adapting `log_operations_threshold` to output only large allocations, or 2. by including `malloc_count.h` in your program and using the user-functions define therein to output memory usage at specific checkpoints. See the directory `test-malloc_count/` in the source code for an example. Tip: Set the locale environment variable `LC_NUMERIC=en_GB` or similar to get comma-separation of thousands in the printed numbers. The directory `test-memprofile/` contains a simple program, which fills a `std::vector` and `std::set` with integers. The memory usage of these containers is profiled using the facilities of `memprofile.h`, which are described verbosely in the source. ## Thread Safety ## The current statistic methods in `malloc_count.c` are **not thread-safe**. However, the general mechanism (as described below) is per-se thread-safe. The only non-safe parts are adding and subtracting from the counters in `inc_count()` and `dec_count()`. The `malloc_count.c` code contains a `#define THREAD_SAFE_GCC_INTRINSICS`, which enables use of gcc's intrinsics for atomic counting operations. If you use gcc, enable this option to make the `malloc_count` tool thread-safe. The functions in `memprofile.h` are not thread-safe. `stack_count` can also be used on local thread stacks. ## Technicalities of Intercepting `libc` Function Calls ## The method used in `malloc_count` to hook the standard heap allocation calls is to provide a source file exporting the symbols "`malloc`", "`free`", etc. These override the libc symbols and thus the functions in `malloc_count` are used instead. However, `malloc_count` does not implement a heap allocator. It loads the symbols "`malloc`", "`free`", etc. directly using the dynamic link loader "`dl`" from the chain of shared libraries. Calls to the overriding "`malloc`" functions are forwarded to the usual libc allocator. To keep track of the size of each allocated memory area, `malloc_count` uses a trick: it prepends each allocation pointer with two `size_t` variables: the allocation size and a sentinel value. Thus when allocating *n* bytes, in truth *n + 16* bytes are requested from the libc `malloc()` to save the size. The sentinel only serves as a check that your program has not overwritten the size information. ## Closing Credits ## The idea for this augmenting interception method is not my own, it was borrowed from Jeremy Kerr . Written 2013-01-21 and 2013-03-16 by Timo Bingmann ================================================ FILE: malloc_count-0.7/memprofile.h ================================================ /****************************************************************************** * memprofile.h * * Class to write the datafile for a memory profile plot using malloc_count. * ****************************************************************************** * Copyright (C) 2013 Timo Bingmann * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see . *****************************************************************************/ #ifndef _MEM_PROFILE_H_ #define _MEM_PROFILE_H_ #include #include #include "malloc_count.h" /** * MemProfile is a class which hooks into malloc_count's callback and writes a * heap usage profile at run-time. * * A usual application will have many heap allocations and deallocations, * therefore these must be aggregated to create a useful plot. This is the main * purposes of MemProfile. However, the "resolution" of discrete aggregation * intervals must be configured manually, as they highly depend on the profiled * application. */ class MemProfile { protected: /// output time resolution double m_time_resolution; /// output memory resolution size_t m_size_resolution; /// function marker for multi-output const char* m_funcname; /// output file FILE* m_file; /// start of current memprofile double m_base_ts; /// start memory usage of current memprofile size_t m_base_mem; /// start stack pointer of memprofile char* m_stack_base; /// timestamp of previous log output double m_prev_ts; /// memory usage of previous log output size_t m_prev_mem; /// maximum memory usage to previous log output size_t m_max; protected: /// template function missing in cmath, absolute difference template static inline Type absdiff(const Type& a, const Type& b) { return (a < b) ? (b - a) : (a - b); } /// time is measured using gettimeofday() or omp_get_wtime() static inline double timestamp() { #ifdef _OPENMP return omp_get_wtime(); #else struct timeval tv; gettimeofday(&tv, NULL); return tv.tv_sec + tv.tv_usec / 1e6; #endif } /// output a data pair (ts,mem) to log file inline void output(double ts, unsigned long long mem) { if (m_funcname) { // more verbose output format fprintf(m_file, "func=%s ts=%g mem=%llu\n", m_funcname, ts - m_base_ts, mem); } else { // simple gnuplot output fprintf(m_file, "%g %llu\n", ts - m_base_ts, mem); } } /// callback invoked by malloc_count when heap usage changes. inline void callback(size_t memcurr) { size_t mem = (memcurr > m_base_mem) ? (memcurr - m_base_mem) : 0; if ((char*)&mem < m_stack_base) // add stack usage mem += m_stack_base - (char*)&mem; double ts = timestamp(); if (m_max < mem) m_max = mem; // keep max usage to last output // check to output a pair if (ts - m_prev_ts > m_time_resolution || absdiff(mem, m_prev_mem) > m_size_resolution ) { output(ts, m_max); m_max = 0; m_prev_ts = ts; m_prev_mem = mem; } } /// static callback for malloc_count, forwards to class method. static void static_callback(void* cookie, size_t memcurr) { return static_cast(cookie)->callback(memcurr); } public: /** Constructor for MemProfile. * @param filepath file to write memprofile log entries to. * @param time_resolution resolution when a log entry is always written. * @param size_resolution resolution when a log entry is always written. * @param funcname enables multi-function output, appends to file. */ MemProfile(const char* filepath, double time_resolution = 0.1, size_t size_resolution = 1024, const char* funcname = NULL) : m_time_resolution( time_resolution ), m_size_resolution( size_resolution ), m_funcname( funcname ), m_base_ts( timestamp() ), m_base_mem( malloc_count_current() ), m_prev_ts( 0 ), m_prev_mem( 0 ), m_max( 0 ) { char stack; m_stack_base = &stack; m_file = fopen(filepath, funcname ? "a" : "w"); malloc_count_set_callback(MemProfile::static_callback, this); } /// Destructor flushes currently aggregated values and closes the file. ~MemProfile() { m_prev_ts = 0; // force flush m_prev_mem = 0; callback( malloc_count_current() ); malloc_count_set_callback(NULL, NULL); fclose(m_file); } }; #endif // _MEM_PROFILE_H_ ================================================ FILE: malloc_count-0.7/stack_count.c ================================================ /****************************************************************************** * stack_count.c * * Header containing two functions to monitor stack usage of a program. * ****************************************************************************** * Copyright (C) 2013 Timo Bingmann * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. *****************************************************************************/ #include "stack_count.h" #include /* default stack size on Linux is 8 MiB, so fill 75% of it. */ static const size_t stacksize = 6*1024*1024; /* "clear" the stack by writing a sentinel value into it. */ void* stack_count_clear(void) { const size_t asize = stacksize / sizeof(uint32_t); uint32_t stack[asize]; /* allocated on stack */ uint32_t* p = stack; while ( p < stack + asize ) *p++ = 0xDEADC0DEu; return p; } /* checks the maximum usage of the stack since the last clear call. */ size_t stack_count_usage(void* lastbase) { const size_t asize = stacksize / sizeof(uint32_t); uint32_t* p = (uint32_t*)lastbase - asize; /* calculate top of last clear. */ while ( *p == 0xDEADC0DEu ) ++p; return ((uint32_t*)lastbase - p) * sizeof(uint32_t); } /*****************************************************************************/ ================================================ FILE: malloc_count-0.7/stack_count.h ================================================ /****************************************************************************** * stack_count.h * * Header containing two functions to monitor stack usage of a program. * ****************************************************************************** * Copyright (C) 2013 Timo Bingmann * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. *****************************************************************************/ #ifndef _STACK_COUNT_H_ #define _STACK_COUNT_H_ #include #ifdef __cplusplus extern "C" { /* for inclusion from C++ */ #endif /* "clear" the stack by writing a sentinel value into it. */ extern void* stack_count_clear(void); /* checks the maximum usage of the stack since the last clear call. */ extern size_t stack_count_usage(void* lastbase); #ifdef __cplusplus } /* extern "C" */ #endif #endif /* _STACK_COUNT_H_ */ /*****************************************************************************/ ================================================ FILE: malloc_count-0.7/test-malloc_count/Makefile ================================================ # Simplistic Makefile for malloc_count example CC = gcc CFLAGS = -g -W -Wall -ansi -I.. LDFLAGS = LIBS = -ldl OBJS = test.o ../malloc_count.o ../stack_count.o all: test %.o: %.c $(CC) $(CFLAGS) -c -o $@ $< test: $(OBJS) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) clean: rm -f *.o test ================================================ FILE: malloc_count-0.7/test-malloc_count/test.c ================================================ /****************************************************************************** * test-malloc_count/test.c * * Small program to test malloc_count hooks and user functions. * ****************************************************************************** * Copyright (C) 2013 Timo Bingmann * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. *****************************************************************************/ #include "malloc_count.h" #include "stack_count.h" #include #include #include void function_use_stack() { char data[64*1024]; memset(data, 1, sizeof(data)); } int main() { /* allocate and free some memory */ void* a = malloc(2*1024*1024); free(a); /* query malloc_count for information */ printf("our peak memory allocation: %lld\n", (long long)malloc_count_peak()); /* use realloc() */ void* b = malloc(3*1024*1024); malloc_count_print_status(); b = realloc(b, 2*1024*1024); malloc_count_print_status(); b = realloc(b, 4*1024*1024); malloc_count_print_status(); free(b); /* some unusual realloc calls */ void* c = realloc(NULL, 1*1024*1024); c = realloc(c, 0); /* show how stack_count works */ { void* base = stack_count_clear(); function_use_stack(); printf("maximum stack usage: %lld\n", (long long)stack_count_usage(base)); } return 0; } /*****************************************************************************/ ================================================ FILE: malloc_count-0.7/test-memprofile/Makefile ================================================ # Simplistic Makefile for malloc_count example CC = gcc CXX = g++ CFLAGS = -g -W -Wall -ansi -I.. CXXFLAGS = -g -W -Wall -ansi -I.. LDFLAGS = LIBS = -ldl OBJS = test.o ../malloc_count.o all: test %.o: %.c $(CC) $(CFLAGS) -c -o $@ $< %.o: %.cc $(CXX) $(CXXFLAGS) -c -o $@ $< test: $(OBJS) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) clean: rm -f *.o test ================================================ FILE: malloc_count-0.7/test-memprofile/memprofile.gnuplot ================================================ #!/usr/bin/env gnuplot set terminal pdf size 28cm,18cm linewidth 2.0 set output "memprofile.pdf" set key top right set grid xtics ytics set title 'Memory Profile of Test Program' set xlabel 'Time [s]' set ylabel 'Memory Usage [MiB]' plot \ 'memprofile.txt' using 1:($2 / 1024/1024) title 'memprofile' with lines ================================================ FILE: malloc_count-0.7/test-memprofile/test.cc ================================================ /****************************************************************************** * test-memprofile/test.cc * * Example to write a memory profile. * ****************************************************************************** * Copyright (C) 2013 Timo Bingmann * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see . *****************************************************************************/ #include "memprofile.h" #include #include int main() { MemProfile mp("memprofile.txt", 0.1, 1024); { std::vector v; for (size_t i = 0; i < 10000000; ++i) v.push_back(i); } { std::set v; for (size_t i = 0; i < 200000; ++i) v.insert(i); } return 0; } ================================================ FILE: obj/.gitignore ================================================ *.o ================================================ FILE: src/.gitignore ================================================ main printer ================================================ FILE: src/ft_printf_tester.h ================================================ #ifndef FT_PRINTF_TESTER_H # define FT_PRINTF_TESTER_H # include # include # include typedef struct s_result { int return_value; char *output_str; ssize_t bytes_read; } t_result; int run_tests(int tests); int check_return(int user_file, int orig_file); void dscribe(char *test_title); int check_result(t_result *user_result, t_result *orig_result, char *params_used); void print_help(char *params_used); void describe(char *test_title); # define ERRORS_LEAK 1 # define ERRORS_BUFFER_OVERFLOW 2 # define ERRORS_SIGSEGV 3 # define BUFSIZE 100 void open_pipes(int *p1, int *p2); void prepare_test(char *err_file, int *outpipe, int *retpipe); void finish_test(int result, int *outpipe, int *retpipe); void fetch_result(t_result *result, char *output_buffer, int *stdout_pipe, int *rtrn_pipe); void handle_errors(int wstatus, t_result *user_r, t_result *orig_r, char *user_output, int *output_pipe, int *return_pipe); # define CAT_C 0b00000000000001 # define CAT_S 0b00000000000010 # define CAT_P 0b00000000000100 # define CAT_D 0b00000000001000 # define CAT_I 0b00000000010000 # define CAT_U 0b00000000100000 # define CAT_X 0b00000001000000 # define CAT_BIG_X 0b00000010000000 # define CAT_PERCENT 0b00000100000000 # define CAT_MANDATORY 0b00001000000000 # define CAT_BONUS 0b00010000000000 # define CAT_BONUS_1 0b00100000000000 # define CAT_BONUS_2 0b01000000000000 #endif ================================================ FILE: src/get_next_line.c ================================================ /* ************************************************************************** */ /* */ /* ::: :::::::: */ /* get_next_line_bonus.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: psergio- +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/06/05 18:06:57 by psergio- #+# #+# */ /* Updated: 2021/06/17 02:55:33 by psergio- ### ########.fr */ /* */ /* ************************************************************************** */ #include "get_next_line.h" void clear_buffer(char **buffer) { if (*buffer) { free(*buffer); } *buffer = NULL; } static char *merge_buffer(char *dest, t_buffer *buf) { size_t dest_len; size_t result_len; char *result; size_t i; int j; dest_len = 0; if (dest) dest_len = gnl_ft_strlen(dest); result_len = dest_len + buf->next_nl - buf->start; result = malloc(sizeof(char) * (result_len + 1)); if (result == NULL) return (NULL); i = 0; while (i < dest_len) { result[i] = dest[i]; i++; } j = buf->start; while (j < buf->next_nl) result[i++] = buf->data[j++]; result[i] = '\0'; return (result); } /** * Fetches `BUFFER_SIZE` characters from file `fd` and append them to the * string *new_line. If a \n is found during the read() call, it appends only * the text until this \n and returns `GNL_LINE_READ`. If no newline character * is found, it appends the whole buffer and returns `GNL_NO_NEWLINE`. If an * error occurs, `GNL_ERROR` will be returned. And if we reached `fd`s end, * `GNL_END_OF_FILE` will be returned. * */ static int append_next_chunk(int fd, char **new_line, t_buffer *buf) { char *merged_str; if (buf->start >= buf->end) { buf->end = read(fd, buf->data, BUFFER_SIZE); buf->start = 0; } if (buf->end == -1) return (GNL_ERROR); buf->next_nl = buf->start; while (buf->next_nl < buf->end && buf->data[buf->next_nl] != '\n') buf->next_nl++; merged_str = merge_buffer(*new_line, buf); buf->start = buf->next_nl + 1; if (merged_str == NULL) return (GNL_ERROR); if (*new_line) free(*new_line); *new_line = merged_str; if (buf->next_nl < buf->end) return (GNL_LINE_READ); if (buf->end < BUFFER_SIZE) return (GNL_END_OF_FILE); return (GNL_NO_NEWLINE); } /** * Fetches the next string from file `fd` and put it in *line. The string * will be truncated on the first \n encountered, or by the end of file. * */ int get_next_line(int fd, char **line) { char *new_line; int result; static t_buffer buffers[FD_SETSIZE]; new_line = NULL; *line = new_line; if (fd < 0 || fd >= FD_SETSIZE) return (GNL_ERROR); if (buffers[fd].data == NULL) { buffers[fd].data = malloc((BUFFER_SIZE) * sizeof(char)); if (buffers[fd].data == NULL) return (GNL_ERROR); buffers[fd].start = BUFFER_SIZE; } result = GNL_NO_NEWLINE; while (result == GNL_NO_NEWLINE) { result = append_next_chunk(fd, &new_line, &buffers[fd]); *line = new_line; } if (result == GNL_END_OF_FILE || result == GNL_ERROR) clear_buffer(&(buffers[fd].data)); return (result); } ================================================ FILE: src/get_next_line.h ================================================ /* ************************************************************************** */ /* */ /* ::: :::::::: */ /* get_next_line_bonus.h :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: psergio- +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/05/31 11:46:38 by psergio- #+# #+# */ /* Updated: 2021/06/08 07:57:49 by psergio- ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef GET_NEXT_LINE_H # define GET_NEXT_LINE_H # include # include typedef struct s_buffer { int start; int next_nl; int end; char *data; } t_buffer; size_t ft_strlcat(char *dest, const char *src, size_t size); size_t gnl_ft_strlen(const char *str); void *ft_calloc(size_t count, size_t size); /** * Retrieves a string that ends with a newline charactere from the file * descriptor `fd` and make the pointer `line` point to it * */ int get_next_line(int fd, char **line); # define GNL_ERROR -1 # define GNL_END_OF_FILE 0 # define GNL_LINE_READ 1 # define GNL_NO_NEWLINE 2 #endif ================================================ FILE: src/get_next_line_utils.c ================================================ /* ************************************************************************** */ /* */ /* ::: :::::::: */ /* get_next_line_utils_bonus.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: psergio- +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/06/02 00:41:05 by psergio- #+# #+# */ /* Updated: 2021/06/08 07:57:29 by psergio- ### ########.fr */ /* */ /* ************************************************************************** */ #include "get_next_line.h" void *ft_calloc(size_t count, size_t size) { size_t i; size_t full_size; char *buffer; full_size = count * size; buffer = malloc(full_size); if (buffer == NULL) return (NULL); i = 0; while (i < full_size) buffer[i++] = 0; return (buffer); } size_t ft_strlcat(char *dest, const char *src, size_t size) { size_t i; size_t j; i = 0; while (dest[i] != '\0' && i < size) i++; j = 0; while (src[j] != '\0' && i + 1 < size) dest[i++] = src[j++]; if (size > i) dest[i] = '\0'; while (src[j++]) i++; return (i); } size_t gnl_ft_strlen(const char *str) { size_t len; len = 0; while (*str++) len++; return (len); } ================================================ FILE: src/helpers.h ================================================ #ifndef HELPERS_H # define HELPERS_H # include "../libtest/libtest.h" # include # define PRINTF(params) __PRINTF_EXPECTED(params, params) # define MALLOC_COUNT 1 # define LEAK_SANITIZER 2 #ifdef __linux__ # define PRINTF_EXPECTED(params, expected) __PRINTF_EXPECTED(params, expected) # define LEAK_CHECKER LEAK_SANITIZER #elif defined __APPLE__ # define PRINTF_EXPECTED(params, expected) __PRINTF_EXPECTED(params, params) # define LEAK_CHECKER MALLOC_COUNT #endif # define READ 0 # define WRITE 1 /* * trying to make the define smaller * or = orig_result; * ur = user_result; * op = stdout_pipe; * rp = rtrn_pipe; * * */ #ifndef ERROR_LIMIT # define ERROR_LIMIT 0 #endif extern int g_tests_failed; extern int g_tests_run; #define __PRINTF_EXPECTED(params, expected) { \ already_printed_help = 0; \ should_run = (g_current_test == g_test_nbr) || (g_test_nbr == 0); \ if (should_run && right_cat) { \ g_tests_run++; \ t_result or, ur; \ int op[2], rp[2]; \ open_pipes(op, rp); \ int child = fork(); \ if (child == 0) { \ prepare_test("files/original_stderr.txt", op, rp); \ int result = printf expected; \ finish_test(result, op, rp); \ } else { \ fetch_result(&or, g_orig_fake_stdout, op, rp); \ waitpid(child, &wstatus, 0); \ } \ open_pipes(op, rp); \ int intermediate_pid = fork(); \ if (intermediate_pid == 0) { \ int worker = fork(); \ if (worker == 0) { \ prepare_test("files/user_stderr.txt", op, rp); \ int result = ft_printf params; \ finish_test(result, op, rp); \ } \ int killer = fork(); \ if (killer == 0) { \ /* sleep well before killing lol */ \ sleep(1); \ _exit(0); \ } \ int exited_pid = wait(&wstatus); \ if (exited_pid == worker) { \ kill(killer, SIGKILL); \ wait(NULL); \ } else { \ kill(worker, SIGKILL); \ wait(&wstatus); \ } \ int status; \ if (WIFEXITED(wstatus)) { \ status = WEXITSTATUS(wstatus); \ } else if(WIFSIGNALED(wstatus)) { \ status = WTERMSIG(wstatus); \ } else { status = -1; } \ _exit(status); \ } else { \ waitpid(intermediate_pid, &wstatus, 0); \ g_test_params = #params; \ handle_errors(wstatus, &ur, &or, g_user_fake_stdout, op, rp); \ } \ } \ if (ERROR_LIMIT > 0 && g_tests_failed > ERROR_LIMIT) \ return (tester_putstr(BOLD RED "Failed on more than 10 tests, stopping...\n"), 5); \ g_current_test++; \ } #endif ================================================ FILE: src/libftprintf.h ================================================ #ifndef LIBFTPRINT_H # define LIBFTPRINT_H int ft_printf(const char *, ...); #endif ================================================ FILE: src/malloc_count.c ================================================ /****************************************************************************** * malloc_count.c * * malloc() allocation counter based on http://ozlabs.org/~jk/code/ and other * code preparing LD_PRELOAD shared objects. * ****************************************************************************** * Copyright (C) 2013 Timo Bingmann * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. *****************************************************************************/ #define _GNU_SOURCE #include #include #include #include #include #include "malloc_count.h" /* user-defined options for output malloc()/free() operations to stderr */ static const int log_operations = 0; /* <-- set this to 1 for log output */ static const size_t log_operations_threshold = 1024*1024; /* option to use gcc's intrinsics to do thread-safe statistics operations */ #define THREAD_SAFE_GCC_INTRINSICS 0 /* function pointer to the real procedures, loaded using dlsym */ typedef void* (*malloc_type)(size_t); typedef void (*free_type)(void*); typedef void* (*realloc_type)(void*, size_t); static malloc_type real_malloc = NULL; static free_type real_free = NULL; static realloc_type real_realloc = NULL; /* a sentinel value prefixed to each allocation */ static const size_t sentinel = 0xDEADC0DE; /* a simple memory heap for allocations prior to dlsym loading */ #define INIT_HEAP_SIZE 1024*1024 static char init_heap[INIT_HEAP_SIZE]; static size_t init_heap_use = 0; static const int log_operations_init_heap = 0; /*****************************************/ /* run-time memory allocation statistics */ /*****************************************/ static long long peak = 0, curr = 0, total = 0; static malloc_count_callback_type callback = NULL; static void* callback_cookie = NULL; /* add allocation to statistics */ static void inc_count(size_t inc) { #if THREAD_SAFE_GCC_INTRINSICS long long mycurr = __sync_add_and_fetch(&curr, inc); if (mycurr > peak) peak = mycurr; total += inc; if (callback) callback(callback_cookie, mycurr); #else if ((curr += inc) > peak) peak = curr; total += inc; if (callback) callback(callback_cookie, curr); #endif } /* decrement allocation to statistics */ static void dec_count(size_t dec) { #if THREAD_SAFE_GCC_INTRINSICS long long mycurr = __sync_sub_and_fetch(&curr, dec); if (callback) callback(callback_cookie, mycurr); #else curr -= dec; if (callback) callback(callback_cookie, curr); #endif } /* user function to return the currently allocated amount of memory */ extern size_t malloc_count_current(void) { return curr; } /* user function to return the peak allocation */ extern size_t malloc_count_peak(void) { return peak; } /* user function to reset the peak allocation to current */ extern void malloc_count_reset_peak(void) { peak = curr; } /* user function which prints current and peak allocation to stderr */ extern void malloc_count_print_status(void) { fprintf(stderr,"malloc_count ### current %'lld, peak %'lld\n", curr, peak); } /* user function to supply a memory profile callback */ void malloc_count_set_callback(malloc_count_callback_type cb, void* cookie) { callback = cb; callback_cookie = cookie; } /****************************************************/ /* exported symbols that overlay the libc functions */ /****************************************************/ /* exported malloc symbol that overrides loading from libc */ extern void* malloc(size_t size) { void* ret; if (size == 0) return NULL; if (real_malloc) { /* call read malloc procedure in libc */ ret = (*real_malloc)(2*sizeof(size_t) + size); inc_count(size); if (log_operations && size >= log_operations_threshold) { fprintf(stderr,"malloc_count ### malloc(%'lld) = %p (current %'lld)\n", (long long)size, (char*)ret + 2*sizeof(size_t), curr); } /* prepend allocation size and check sentinel */ ((size_t*)ret)[0] = size; ((size_t*)ret)[1] = sentinel; return (char*)ret + 2*sizeof(size_t); } else { if (init_heap_use + sizeof(size_t) + size > INIT_HEAP_SIZE) { fprintf(stderr,"malloc_count ### init heap full !!!\n"); exit(EXIT_FAILURE); } ret = init_heap + init_heap_use; init_heap_use += 2*sizeof(size_t) + size; /* prepend allocation size and check sentinel */ ((size_t*)ret)[0] = size; ((size_t*)ret)[1] = sentinel; if (log_operations_init_heap) { fprintf(stderr,"malloc_count ### malloc(%'lld) = %p on init heap\n", (long long)size, (char*)ret + 2*sizeof(size_t)); } return (char*)ret + 2*sizeof(size_t); } } /* exported free symbol that overrides loading from libc */ extern void free(void* ptr) { size_t size; if (!ptr) return; /* free(NULL) is no operation */ if ((char*)ptr >= init_heap && (char*)ptr <= init_heap + init_heap_use) { if (log_operations_init_heap) { fprintf(stderr,"malloc_count ### free(%p) on init heap\n", ptr); } return; } if (!real_free) { fprintf(stderr,"malloc_count ### free(%p) outside init heap and without real_free !!!\n", ptr); return; } ptr = (char*)ptr - 2*sizeof(size_t); if (((size_t*)ptr)[1] != sentinel) { fprintf(stderr,"malloc_count ### free(%p) has no sentinel !!! memory corruption?\n", ptr); } size = ((size_t*)ptr)[0]; dec_count(size); if (log_operations && size >= log_operations_threshold) { fprintf(stderr,"malloc_count ### free(%p) -> %'lld (current %'lld)\n", ptr, (long long)size, curr); } (*real_free)(ptr); } /* exported calloc() symbol that overrides loading from libc, implemented using our malloc */ extern void* calloc(size_t nmemb, size_t size) { void* ret; size *= nmemb; if (!size) return NULL; ret = malloc(size); memset(ret, 0, size); return ret; } /* exported realloc() symbol that overrides loading from libc */ extern void* realloc(void* ptr, size_t size) { void* newptr; size_t oldsize; if ((char*)ptr >= (char*)init_heap && (char*)ptr <= (char*)init_heap + init_heap_use) { if (log_operations_init_heap) { fprintf(stderr,"malloc_count ### realloc(%p) = on init heap\n", ptr); } ptr = (char*)ptr - 2*sizeof(size_t); if (((size_t*)ptr)[1] != sentinel) { fprintf(stderr,"malloc_count ### realloc(%p) has no sentinel !!! memory corruption?\n", ptr); } oldsize = ((size_t*)ptr)[0]; if (oldsize >= size) { /* keep old area, just reduce the size */ ((size_t*)ptr)[0] = size; return (char*)ptr + 2*sizeof(size_t); } else { /* allocate new area and copy data */ ptr = (char*)ptr + 2*sizeof(size_t); newptr = malloc(size); memcpy(newptr, ptr, oldsize); free(ptr); return newptr; } } if (size == 0) { /* special case size == 0 -> free() */ free(ptr); return NULL; } if (ptr == NULL) { /* special case ptr == 0 -> malloc() */ return malloc(size); } ptr = (char*)ptr - 2*sizeof(size_t); if (((size_t*)ptr)[1] != sentinel) { fprintf(stderr,"malloc_count ### free(%p) has no sentinel !!! memory corruption?\n", ptr); } oldsize = ((size_t*)ptr)[0]; dec_count(oldsize); inc_count(size); newptr = (*real_realloc)(ptr, 2*sizeof(size_t) + size); if (log_operations && size >= log_operations_threshold) { if (newptr == ptr) fprintf(stderr,"malloc_count ### realloc(%'lld -> %'lld) = %p (current %'lld)\n", (long long)oldsize, (long long)size, newptr, curr); else fprintf(stderr,"malloc_count ### realloc(%'lld -> %'lld) = %p -> %p (current %'lld)\n", (long long)oldsize, (long long)size, ptr, newptr, curr); } ((size_t*)newptr)[0] = size; return (char*)newptr + 2*sizeof(size_t); } static __attribute__((constructor)) void init(void) { char *error; setlocale(LC_NUMERIC, ""); /* for better readable numbers */ dlerror(); real_malloc = (malloc_type)dlsym(RTLD_NEXT, "malloc"); if ((error = dlerror()) != NULL) { fprintf(stderr, "malloc_count ### error %s\n", error); exit(EXIT_FAILURE); } real_realloc = (realloc_type)dlsym(RTLD_NEXT, "realloc"); if ((error = dlerror()) != NULL) { fprintf(stderr, "malloc_count ### error %s\n", error); exit(EXIT_FAILURE); } real_free = (free_type)dlsym(RTLD_NEXT, "free"); if ((error = dlerror()) != NULL) { fprintf(stderr, "malloc_count ### error %s\n", error); exit(EXIT_FAILURE); } } static __attribute__((destructor)) void finish(void) { fprintf(stderr,"malloc_count ### exiting, total: %'lld, peak: %'lld, current: %'lld\n", total, peak, curr); } /*****************************************************************************/ ================================================ FILE: src/malloc_count.h ================================================ /****************************************************************************** * malloc_count.h * * Header containing prototypes of user-callable functions to retrieve run-time * information about malloc()/free() allocation. * ****************************************************************************** * Copyright (C) 2013 Timo Bingmann * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. *****************************************************************************/ #ifndef _MALLOC_COUNT_H_ #define _MALLOC_COUNT_H_ #include #ifdef __cplusplus extern "C" { /* for inclusion from C++ */ #endif /* returns the currently allocated amount of memory */ extern size_t malloc_count_current(void); /* returns the current peak memory allocation */ extern size_t malloc_count_peak(void); /* resets the peak memory allocation to current */ extern void malloc_count_reset_peak(void); /* typedef of callback function */ typedef void (*malloc_count_callback_type)(void* cookie, size_t current); /* supply malloc_count with a callback function that is invoked on each change * of the current allocation. The callback function must not use * malloc()/realloc()/free() or it will go into an endless recursive loop! */ extern void malloc_count_set_callback(malloc_count_callback_type cb, void* cookie); /* user function which prints current and peak allocation to stderr */ extern void malloc_count_print_status(void); #ifdef __cplusplus } /* extern "C" */ #endif #endif /* _MALLOC_COUNT_H_ */ /*****************************************************************************/ ================================================ FILE: src/system_printer.c ================================================ #include #include #include #include int main(int argc, char *argv[]) { if (argc == 2) { int file = open("./files/system_output.txt", O_RDWR | O_CREAT | O_TRUNC, 0644); dup2(file, 1); char *test_number = argv[1]; if (strcmp(test_number, "1") == 0) { printf("This is a simple test\n"); } } } ================================================ FILE: src/tests.c ================================================ #include "ft_printf_tester.h" #include "helpers.h" #include "libftprintf.h" extern char g_orig_fake_stdout[BUFSIZ]; extern char g_user_fake_stdout[BUFSIZ]; extern char *g_test_params; extern int g_test_nbr; extern int already_printed_help; extern int g_current_test; extern int g_all_bonus; int right_cat = 1; int run_tests(int test_cat) { int wstatus; char *null_str = NULL; int should_run = 1; describe("basic test"); PRINTF(("1, 2, 3, -d test, testing, 0.4s sound, 1, 2, 3xp, sound, -*dtest")); // if no cateogry was specified, then run all of the categories right_cat = test_cat ? test_cat & (CAT_C | CAT_MANDATORY) : 1; describe("\n%c basic"); PRINTF(("%c", 'a')); PRINTF(("%c%c%c*", '\0', '1', 1)); PRINTF(("%c small string", 'a')); PRINTF(("%c small string", '\0')); PRINTF(("the char is: %c", 'a')); PRINTF(("the char is: %c", '\0')); PRINTF(("n%cs", 'a')); PRINTF(("%c%c%c%c%c", 'a', 'i', 'u', 'e', 'o')); PRINTF(("l%cl%cl%cl%cl%c", 'a', 'i', 'u', 'e', 'o')); PRINTF(("l%cl%cl%cl%cl%c", '\0', '\0', '\0', 'e', '\0')); right_cat = test_cat ? test_cat & (CAT_S | CAT_MANDATORY) : 1; describe("\n%s basic"); PRINTF(("%s", "")); PRINTF(("this is a %s", "test")); PRINTF(("this is 1 %s with %s %s", "test", "multiple", "strings")); PRINTF(("%s%s%s%s", "This ", "is", " an ugly ", "test")); PRINTF(("%s", "This is a rather simple test.")); PRINTF(("%s", "-2")); PRINTF(("%s", "-24")); PRINTF(("%s", "-stop")); PRINTF(("%s", "-0003")); PRINTF(("%s", "000-0003")); PRINTF(("%s", "0x42")); PRINTF(("%s", "0x0000042")); PRINTF(("some naugty tests: %s", "0000%")); PRINTF(("some naugty tests: %s", " %")); PRINTF(("some naugty tests: %s", "%000")); PRINTF(("%s", "bea thought but bea forgot the loop that the chars cause she was floaty during the amsterdam siren call. she got me by surprise you probably read my mind that look in your eyes and judging by your own cries you probably read my mind this is a really long string and if you see this you must look at your return values!kthxbai this must have more than 127 chars by now isnt it ok 4242 4 life 1337 code everyday to the moon!")); PRINTF(("%s", null_str)); PRINTF(("%s everywhere", null_str)); PRINTF(("everywhere %s", null_str)); PRINTF(("%s", "h")); PRINTF(("t%st%s", "a", "u")); PRINTF(("%s%s%s%s%s%s", "a", "i", "u", "e", "o", "l")); right_cat = test_cat ? test_cat & (CAT_P | CAT_MANDATORY) : 1; describe("\n%p basic"); int test = 42; PRINTF(("%p", &test)); PRINTF(("%p is a virtual memory address", &test)); PRINTF(("The address of the answer is %p", &test)); PRINTF(("The address is %p, so what?", &test)); int *ptr = &test; PRINTF(("A pointer at %p points to %p", &test, &ptr)); PRINTF(("This %p is a very strange address", (void *)(long int)test)); char *mallocked = malloc(2); PRINTF(("This %p is an address from the heap", mallocked); free(mallocked);); free(mallocked); PRINTF(("%p", NULL)); PRINTF(("The NULL macro represents the %p address", NULL)); PRINTF(("This %p is even stranger", (void *)-1)); right_cat = test_cat ? test_cat & (CAT_D | CAT_MANDATORY) : 1; describe("\n%d basic"); PRINTF(("%d", 0)); PRINTF(("%d", 10)); PRINTF(("%d, %d", 10, 20)); PRINTF(("%d%d%d%d", 10, 20, 30, 5)); PRINTF(("%d %d", 2147483647, (int)-2147483648)); PRINTF(("42 - 84 is %d", -42)); PRINTF(("%d C is the lowest temperature in the universe", -273)); PRINTF(("%dxC is the lowest temperature in the universe", -273)); PRINTF(("%dsC is the lowest temperature in the universe", -273)); PRINTF(("%dpC is the lowest temperature in the universe", -273)); right_cat = test_cat ? test_cat & (CAT_I | CAT_MANDATORY) : 1; describe("\n%i basic"); PRINTF(("%i", 0)); PRINTF(("%i", 10)); PRINTF(("%i, %i", 10, 23)); PRINTF(("%i%i%i%i%i%i%i", 10, 23, -2, 37, 200, -9999, 977779)); PRINTF(("%i %i", 2147483647, (int)-2147483648)); PRINTF(("%iq%i", 21447, -21648)); right_cat = test_cat ? test_cat & (CAT_U | CAT_MANDATORY) : 1; describe("\n%u basic"); PRINTF(("%u", 42)); PRINTF(("%u", 0)); PRINTF(("%u", 2147483647)); PRINTF(("%u", (unsigned int)2147483648)); PRINTF(("%u", (unsigned int)3147983649)); PRINTF(("%u", (unsigned int)4294967295)); PRINTF(("%u to the power of %u is %u", 2, 32, (unsigned int)4294967295)); PRINTF(("%u%u%u%u", (unsigned int)429896724, 0, 32, (unsigned int)4294967295)); right_cat = test_cat ? test_cat & (CAT_X | CAT_MANDATORY ) : 1; describe("\n%x basic"); PRINTF(("%x", 0)); PRINTF(("%x", 1)); PRINTF(("%x", 10)); PRINTF(("%x", 16)); PRINTF(("%x", 160)); PRINTF(("%x", 255)); PRINTF(("%x", 256)); PRINTF(("%x", 3735929054u)); PRINTF(("the password is %x", 3735929054u)); PRINTF(("%x is the definitive answer", 66u)); PRINTF(("this is the real number: %x", -1u)); right_cat = test_cat ? test_cat & (CAT_BIG_X | CAT_MANDATORY ): 1; describe("\n%X basic"); PRINTF(("%X", 0)); PRINTF(("%X", 1)); PRINTF(("%X", 10)); PRINTF(("%X", 16)); PRINTF(("%X", 160)); PRINTF(("%X", 255)); PRINTF(("%X", 256)); PRINTF(("%X", (unsigned int)3735929054)); PRINTF(("the password is %X", (unsigned int)3735929054)); PRINTF(("%X is the definitive answer", (unsigned int)66)); PRINTF(("this is the real number: %X", (unsigned int)-1)); right_cat = test_cat ? test_cat & (CAT_PERCENT | CAT_MANDATORY) : 1; describe("\n%% basic"); PRINTF(("%%")); PRINTF(("100%%")); PRINTF(("%%p is how you print a pointer in printf")); PRINTF(("the '%%%%' is used to print a %% in printf")); PRINTF(("%%%%%%%%%%%%%%%%")); PRINTF(("%%c%%s%%p%%d%%i%%u%%x%%X%%")); right_cat = test_cat ? test_cat & CAT_MANDATORY : 1; describe("\nmix"); PRINTF(("%c - %s - %p %d - %i - %u - %x %X %%", 'a', "test", (void *)0xdeadc0de, 20, -20, -1, -1, 200000000)); PRINTF(("%c - %s - %p %d - %i - %u - %x %X %%", '\0', "test", (void *)-1, 20, -20, -1, -1, 200000000)); PRINTF(("%c - %s - %p %d - %i - %u - %x %X %%", 'c', "", (void *)-1, 20, -20, -1, -1, 200000000)); PRINTF(("%i - %s - %p %d - %c - %u - %x %X %%", 20, "", (void *)-1, '\0', -20, -1, -1, 200000000)); PRINTF(("%c - %s - %p %d - %i - %u - %x %X %%", 'b', null_str, NULL, 20, -20, -1, -1, 200000000)); PRINTF(("%c %s - %p - %d - %i %u - %x - %X %%", '\0', null_str, (void *)0xdeadc0de, 0, (int)-2147483648, -1, -1, 200000000)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_C && test_cat & CAT_BONUS_1) : 1; describe("\n%c and widths"); PRINTF(("%1c", 'a')) PRINTF(("%1c", '\0')) PRINTF(("%10c", 'b')) PRINTF(("%10c", '\0')) PRINTF(("%2c", 'c')) PRINTF(("there are 15 spaces between this text and the next char%15c", 'd')) PRINTF(("%5chis paragraph is indented", 't')) PRINTF(("%5c now you see", '\0')) PRINTF(("The number %7c represents luck", '7')) right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_S && test_cat & CAT_BONUS_1) : 1; describe("\n%s and widths"); PRINTF(("%1s", "a")); PRINTF(("%1s", "abc")); PRINTF(("%7s", "a")); PRINTF(("%7s", "abc")); PRINTF(("%1s", "-42")); PRINTF(("%2s", "-42")); PRINTF(("%3s", "-42")); PRINTF(("%4s", "-42")); PRINTF(("%5s", "-42")); PRINTF(("%6s", "-42")); PRINTF(("%1s", null_str)); PRINTF(("%2s", null_str)); PRINTF(("%5s", null_str)); PRINTF(("%6s", null_str)); PRINTF(("%7s", null_str)); PRINTF(("%7s is as easy as %13s", "abc", "123")); PRINTF(("%13s are the three first letter of the %3s", "a, b and c", "alphabet")); PRINTF(("%s%13s%42s%3s", "a, b and c", " are letters", " of the", " alphabet")); PRINTF(("%sc%13sd%42sp%3sx", "a, b and c", " are letters", " of the", " alphabet")); PRINTF(("%sc%13sd%42sp%3sx", "a, b and c", " are letters", " of the", " alphabet")); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_P && test_cat & CAT_BONUS_1) : 1; describe("\n%p and widths"); char c; PRINTF(("%1p", &c)); PRINTF(("%30p", &c)); PRINTF(("%12p", (void *)0x7ffe6b8e60c6)); PRINTF(("%13p", (void *)0x7ffe6b8e60c5)); PRINTF(("%14p", (void *)0x7ffe6b8e60c4)); PRINTF(("the address is %12p", (void *)0x7ffe6b8e60c7)); PRINTF(("the address is %13p", (void *)0x7ffe6b8e60c8)); PRINTF(("the address is %14p", (void *)0x7ffe6b8e60c9)); PRINTF(("the address is %1p", (void *)0)); PRINTF(("the address is %2p", (void *)0)); PRINTF(("the address is %3p", (void *)0)); PRINTF(("the address is %4p", (void *)0)); PRINTF(("the address is %8p", (void *)0)); PRINTF(("%12p is the address", (void *)0x7ffe6b8e60c7)); PRINTF(("%13p is the address", (void *)0x7ffe6b8e60c8)); PRINTF(("%14p is the address", (void *)0x7ffe6b8e60c9)); PRINTF(("%1p is the address", (void *)0)); PRINTF(("%2p is the address", (void *)0)); PRINTF(("%3p is the address", (void *)0)); PRINTF(("%4p is the address", (void *)0)); PRINTF(("%8p is the address", (void *)0)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_D && test_cat & CAT_BONUS_1) : 1; describe("\n%d and widths"); PRINTF(("%1d", 0)); PRINTF(("%1d", -4)); PRINTF(("%10d", 42)); PRINTF(("%42d", 42000)); PRINTF(("%20d", -42000)); PRINTF(("wait for it... %50d", 42)); PRINTF(("%20d is how many tests are going to be made", 8000)); PRINTF(("%5d", 2147483647)); PRINTF(("%30d", 2147483647)); PRINTF(("%10d", 2147483647)); PRINTF(("%5d", (int)-2147483648)); PRINTF(("%30d", (int)-2147483648)); PRINTF(("%10d", (int)-2147483648)); PRINTF(("%11d", (int)-2147483648)); PRINTF(("%12d", (int)-2147483648)); PRINTF(("%12d, %20d, %2d, %42d", (int)-2147483648, 3, 30, -1)); PRINTF(("%12d, %d, %2d, %42d", (int)-2147483648, 3, 30, -1)); PRINTF(("%14d%20d%2d%d", (int)-2147483648, 3, 30, -1)); PRINTF(("%14dc%20ds%2dx%du", (int)-2147483648, 3, 30, -1)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_I && test_cat & CAT_BONUS_1) : 1; describe("\n%i and widths"); PRINTF(("%1i", 0)); PRINTF(("%1i", -4)); PRINTF(("%10i", 42)); PRINTF(("%42i", 42000)); PRINTF(("%20i", -42000)); PRINTF(("wait for it... %50i", 42)); PRINTF(("%20i is how many tests are going to be made", 8000)); PRINTF(("%5i", 2147483647)); PRINTF(("%30i", 2147483647)); PRINTF(("%10i", 2147483647)); PRINTF(("%5i", (int)-2147483648)); PRINTF(("%30i", (int)-2147483648)); PRINTF(("%10i", (int)-2147483648)); PRINTF(("%11i", (int)-2147483648)); PRINTF(("%12i", (int)-2147483648)); PRINTF(("%12i, %20i, %2i, %42i", (int)-2147483648, 3, 30, -1)); PRINTF(("%12i, %i, %2i, %42i", (int)-2147483648, 3, 30, -1)); PRINTF(("%14i%20i%2i%i", (int)-2147483648, 3, 30, -1)); PRINTF(("%14ic%20is%2ix%du", (int)-2147483648, 3, 30, -1)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_U && test_cat & CAT_BONUS_1) : 1; describe("\n%u and widths"); PRINTF(("%1u", 0)); PRINTF(("%2u", 1)); PRINTF(("%1u", 1000)); PRINTF(("%4u", 1000)); PRINTF(("%30u", 1000)); PRINTF(("%9u is the biggest unsigned int", (unsigned int)-1)); PRINTF(("%10uis the biggest unsigned int", (unsigned int)-1)); PRINTF(("%11uis the biggest unsigned int", (unsigned int)-1)); PRINTF(("the biggest unsigned int is %9u", (unsigned int)-1)); PRINTF(("the biggest unsigned int is %10u", (unsigned int)-1)); PRINTF(("the biggest unsigned int is %11u", (unsigned int)-1)); PRINTF(("Here are some numbers: %1u%2u%5u%3u%9u and %ui", 11, (unsigned int)-1, 2, 200, 3, 10)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_X && test_cat & CAT_BONUS_1) : 1; describe("\n%x and widths"); PRINTF(("%1x", 0)); PRINTF(("%2x", 1)); PRINTF(("%3x", 10)); PRINTF(("%1x", 16)); PRINTF(("%2x", 160)); PRINTF(("%3x", 255)); PRINTF(("%42x", 256)); PRINTF(("%7x", (unsigned int)3735929054)); PRINTF(("%8x", (unsigned int)3735929054)); PRINTF(("%9x", (unsigned int)3735929054)); PRINTF(("the password is %7x", (unsigned int)3735929054)); PRINTF(("the password is %8x", (unsigned int)3735929054)); PRINTF(("the password is %9x", (unsigned int)3735929054)); PRINTF(("%1x is the definitive answer", (unsigned int)66)); PRINTF(("%2x is the definitive answer", (unsigned int)66)); PRINTF(("%3x is the definitive answer", (unsigned int)66)); PRINTF(("this is the real number: %7x", (unsigned int)-1)); PRINTF(("this is the real number: %8x", (unsigned int)-1)); PRINTF(("this is the real number: %9x", (unsigned int)-1)); PRINTF(("%1x%2x%9x", (unsigned int)-1, 0xf0ca, 123456)); PRINTF(("%1xis doomed%2xpost%9xX args", (unsigned int)-1, 0xf0b1a, 7654321)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_BIG_X && test_cat & CAT_BONUS_1) : 1; describe("\n%X and widths"); PRINTF(("%1X", 0)); PRINTF(("%2X", 1)); PRINTF(("%3X", 10)); PRINTF(("%1X", 16)); PRINTF(("%2X", 160)); PRINTF(("%3X", 255)); PRINTF(("%42X", 256)); PRINTF(("%7X", (unsigned int)3735929054)); PRINTF(("%8X", (unsigned int)3735929054)); PRINTF(("%9X", (unsigned int)3735929054)); PRINTF(("the password is %7X", (unsigned int)3735929054)); PRINTF(("the password is %8X", (unsigned int)3735929054)); PRINTF(("the password is %9X", (unsigned int)3735929054)); PRINTF(("%1X is the definitive answer", (unsigned int)66)); PRINTF(("%2X is the definitive answer", (unsigned int)66)); PRINTF(("%3X is the definitive answer", (unsigned int)66)); PRINTF(("this is the real number: %7X", (unsigned int)-1)); PRINTF(("this is the real number: %8X", (unsigned int)-1)); PRINTF(("this is the real number: %9X", (unsigned int)-1)); PRINTF(("%1X%2X%9X", (unsigned int)-1, 0xf0ca, 123456)); PRINTF(("%1Xis doomed%2Xpost%9Xx args", (unsigned int)-1, 0xf0b1a, 7654321)); describe("\n%s and precisions"); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_S && test_cat & CAT_BONUS_1) : 1; PRINTF(("%.s", "hi there")); PRINTF(("%.0s", "hi there")); PRINTF(("%.1s", "hi there")); PRINTF(("%.2s", "hi there")); PRINTF(("%.3s", "hi there")); PRINTF(("%.4s", "hi there")); PRINTF(("%.7s", "hi there")); PRINTF(("%.8s", "hi there")); PRINTF(("%.9s", "hi there")); PRINTF(("%.12s", "hi there")); PRINTF(("%.s", "-42")); PRINTF(("%.0s", "-42")); PRINTF(("%.1s", "-42")); PRINTF(("%.2s", "-42")); PRINTF(("%.3s", "-42")); PRINTF(("%.4s", "-42")); PRINTF(("%.7s", "-42")); PRINTF(("%.1s", null_str)); PRINTF(("%.2s", null_str)); PRINTF(("%.5s", null_str)); PRINTF(("%.6s", null_str)); PRINTF(("%.7s", null_str)); PRINTF(("%.2s, motherfucker", "hi there")); PRINTF(("This %.3s a triumph ", "wasabi")); PRINTF(("%.4s making a %.4s here: %.13s", "I'm delighted", "notation", "HUGE SUCCESS!")); PRINTF(("It's %.4s to over%.50s my%s", "hardware", "state", " satisfaction")); PRINTF(("%.11s%.6s%.4s", "Aperture", " Scientists", "ce")); PRINTF(("%1.s", "21-school.ru")); //Rustem (bnidia) PRINTF(("%10.1s", "21-school.ru")); //Rustem (bnidia) right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_D && test_cat & CAT_BONUS_1) : 1; describe("\n%d and precisions"); PRINTF(("%.1d", 2)) PRINTF(("%.2d", 3)) PRINTF(("%.4d", 32)) PRINTF(("%.3d", 420000)) PRINTF(("%.0d", 420000)) PRINTF(("%.3d", -1)) PRINTF(("%.3d", -1234)) PRINTF(("%.4d", -1234)) PRINTF(("%.5d", -1234)) PRINTF(("%.5d", (int)-2147483648)) PRINTF(("%.9d", (int)-2147483648)) PRINTF(("%.10d", (int)-2147483648)) PRINTF(("%.11d", (int)-2147483648)) PRINTF(("%.12d", (int)-2147483648)) PRINTF(("%.13d", (int)-2147483648)) PRINTF(("%.5d", 2147483647)) PRINTF(("%.9d", 2147483647)) PRINTF(("%.10d", 2147483647)) PRINTF(("%.11d", 2147483647)) PRINTF(("%.12d", 2147483647)) PRINTF(("%.0d", 2)) PRINTF(("%.0d", 2147483647)) PRINTF(("%.0d", 0)) PRINTF(("%.0d", 10)) PRINTF(("%.d", 10)) PRINTF(("%.d", 0)) PRINTF(("I'm gonna watch %.3d", 7)) PRINTF(("%.3d is the movie I'm gonna watch", 7)) PRINTF(("Then take these %.7d things and get the hell out of here", 2)) PRINTF(("Bla %.2di bla %.5dsbla bla %.dx bla %.d", 127, 42, 1023, 0)) PRINTF(("%.4d%.2d%.20d%.0d%.0d%.d%.d%.d", 127, 0, 1023, 0, (int)-2147483648, 0, 1, (int)-2147483648)) right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_I && test_cat & CAT_BONUS_1) : 1; describe("\n%i and precisions"); PRINTF(("%.1i", 7)) PRINTF(("%.3i", 7)) PRINTF(("%.2i", 3)) PRINTF(("%.4i", 32)) PRINTF(("%.3i", 420000)) PRINTF(("%.0i", 420000)) PRINTF(("%.3i", -1)) PRINTF(("%.3i", -1234)) PRINTF(("%.4i", -1234)) PRINTF(("%.5i", -1234)) PRINTF(("%.5i", (int)-2147483648)) PRINTF(("%.9i", (int)-2147483648)) PRINTF(("%.10i", (int)-2147483648)) PRINTF(("%.11i", (int)-2147483648)) PRINTF(("%.12i", (int)-2147483648)) PRINTF(("%.13i", (int)-2147483648)) PRINTF(("%.5i", 2147483647)) PRINTF(("%.9i", 2147483647)) PRINTF(("%.10i", 2147483647)) PRINTF(("%.11i", 2147483647)) PRINTF(("%.12i", 2147483647)) PRINTF(("%.0i", 2)) PRINTF(("%.0i", 2147483647)) PRINTF(("%.0i", 0)) PRINTF(("%.0i", 10)) PRINTF(("%.i", 10)) PRINTF(("%.i", 0)) PRINTF(("I'm gonna watch %.3i", 7)) PRINTF(("%.3i is the movie I'm gonna watch", 7)) PRINTF(("Then take these %.7i things and get the hell out of here", 2)) PRINTF(("Bla %.2ii bla %.5isbla bla %.ix bla %.i", 127, 42, 1023, 0)) PRINTF(("%.4i%.2i%.20i%.0i%.0i%.i%.i%.i", 127, 0, 1023, 0, (int)-2147483648, 0, 1, (int)-2147483648)) right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_U && test_cat & CAT_BONUS_1) : 1; describe("\n%u and precisions"); PRINTF(("%.1u", 1)) PRINTF(("%.2u", 1)) PRINTF(("%.2u", 0)) PRINTF(("%.0u", 0)) PRINTF(("%.u", 0)) PRINTF(("%.2u", 30000)) PRINTF(("%.20u", 30000)) PRINTF(("%.0u", (unsigned int)-1)) PRINTF(("%.5u", (unsigned int)-1)) PRINTF(("%.9u", (unsigned int)-1)) PRINTF(("%.10u", (unsigned int)-1)) PRINTF(("%.11u", (unsigned int)-1)) PRINTF(("%.10uis a big number", (unsigned int)-1)) PRINTF(("%.0uis a big number", (unsigned int)-1)) PRINTF(("%.4us a big number", (unsigned int)-1)) PRINTF(("%.9uxs a big number", (unsigned int)-1)) PRINTF(("%.11ups a big number", (unsigned int)-1)) PRINTF(("the number is %.0u", (unsigned int)-1)) PRINTF(("the number is %.u", (unsigned int)-1)) PRINTF(("the number is %.5u", (unsigned int)-1)) PRINTF(("the number is %.9u", (unsigned int)-1)) PRINTF(("the number is %.10u", (unsigned int)-1)) PRINTF(("the number is %.11u", (unsigned int)-1)) PRINTF(("the number is %.11u", (unsigned int)-1)) PRINTF(("%.0uis a big number", 0)) PRINTF(("%.4us a big number", 0)) PRINTF(("the number is %.0u", 0)) PRINTF(("the number is %.u", 0)) PRINTF(("the number is %.5u", 0)) PRINTF(("%u%.5u%.0u%.u%.9u", 5, 55, 2, 0, 42)) PRINTF(("%us%.5ui%.0uc%.up%.9ux", 5, 55, 2, 0, 42)) right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_X && test_cat & CAT_BONUS_1) : 1; describe("\n%x and precisions"); PRINTF(("%.1x", 0xa)) PRINTF(("%.4x", 11)) PRINTF(("%.0x", 0)) PRINTF(("%.1x", -1)) PRINTF(("%.10x", -1)) PRINTF(("%.14x", -1)) PRINTF(("%.8x", 0)) PRINTF(("%.2x", 30000)) PRINTF(("%.20x", 30000)) PRINTF(("%.0x", (unsigned int)-1)) PRINTF(("%.5x", (unsigned int)-1)) PRINTF(("%.9x", (unsigned int)-1)) PRINTF(("%.10x", (unsigned int)-1)) PRINTF(("%.11x", (unsigned int)-1)) PRINTF(("%.10xis a big number", (unsigned int)-1)) PRINTF(("%.0xis a big number", (unsigned int)-1)) PRINTF(("%.4xs a big number", (unsigned int)-1)) PRINTF(("%.9xxs a big number", (unsigned int)-1)) PRINTF(("%.11xps a big number", (unsigned int)-1)) PRINTF(("the number is %.0x", (unsigned int)-1)) PRINTF(("the number is %.x", (unsigned int)-1)) PRINTF(("the number is %.5x", (unsigned int)-1)) PRINTF(("the number is %.9x", (unsigned int)-1)) PRINTF(("the number is %.10x", (unsigned int)-1)) PRINTF(("the number is %.11x", (unsigned int)-1)) PRINTF(("the number is %.11x", (unsigned int)-1)) PRINTF(("%.0xis a big number", 0)) PRINTF(("%.4xs a big number", 0)) PRINTF(("the number is %.0x", 0)) PRINTF(("the number is %.x", 0)) PRINTF(("the number is %.5x", 0)) PRINTF(("%x%.5x%.0x%.x%.9x", 5, 55, 2, 0, 42)) PRINTF(("%xs%.5xi%.0xc%.xp%.9xu", 5, 55, 2, 0, 42)) right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_BIG_X && test_cat & CAT_BONUS_1) : 1; describe("\n%X and precisions"); PRINTF(("%.1X", 0xa)) PRINTF(("%.4X", 11)) PRINTF(("%.0X", 0)) PRINTF(("%.1X", -1)) PRINTF(("%.10X", -1)) PRINTF(("%.14X", -1)) PRINTF(("%.8X", 0)) PRINTF(("%.2X", 30000)) PRINTF(("%.20X", 30000)) PRINTF(("%.0X", (unsigned int)-1)) PRINTF(("%.5X", (unsigned int)-1)) PRINTF(("%.9X", (unsigned int)-1)) PRINTF(("%.10X", (unsigned int)-1)) PRINTF(("%.11X", (unsigned int)-1)) PRINTF(("%.10Xis a big number", (unsigned int)-1)) PRINTF(("%.0Xis a big number", (unsigned int)-1)) PRINTF(("%.4Xs a big number", (unsigned int)-1)) PRINTF(("%.9XXs a big number", (unsigned int)-1)) PRINTF(("%.11Xps a big number", (unsigned int)-1)) PRINTF(("the number is %.0X", (unsigned int)-1)) PRINTF(("the number is %.X", (unsigned int)-1)) PRINTF(("the number is %.5X", (unsigned int)-1)) PRINTF(("the number is %.9X", (unsigned int)-1)) PRINTF(("the number is %.10X", (unsigned int)-1)) PRINTF(("the number is %.11X", (unsigned int)-1)) PRINTF(("the number is %.11X", (unsigned int)-1)) PRINTF(("%.0Xis a big number", 0)) PRINTF(("%.4Xs a big number", 0)) PRINTF(("the number is %.0X", 0)) PRINTF(("the number is %.X", 0)) PRINTF(("the number is %.5X", 0)) PRINTF(("%X%.5X%.0X%.X%.9X", 5, 55, 2, 0, 42)) PRINTF(("%Xs%.5Xi%.0Xc%.Xp%.9Xu", 5, 55, 2, 0, 42)) right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_C && test_cat & CAT_BONUS_1) : 1; describe("\n%c, widths and -"); // this is literally a negative width '-' PRINTF(("%-c", 'p')); PRINTF(("%-1c", 'b')); PRINTF(("%-5c", 'w')); PRINTF((" kk daora%-5cblz", 'w')); PRINTF(("%-20carigatou", 'w')); PRINTF(("%-c%-c%-4c%-11c", 'a', 'b', 'c', 'd')); PRINTF(("%-ci%-cp%4cs%-11cx", 'a', 'b', 'c', 'd')); PRINTF(("%----ci%---cp%4cs%--11cx", 'a', 'b', 'c', 'd')); PRINTF(("%-c%-c%c*", 0, '1', 1)); PRINTF(("%-2c%-3c%-4c*", 0, 'a', 0)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_S && test_cat & CAT_BONUS_1) : 1; describe("\n%s, widths, precisions and -"); PRINTF(("%-9sScience!", "Aperture")); PRINTF(("We %-s what we %8s, %-2s we %-20s", "do", "must", "because", "can")); PRINTF(("%--4s %s %------------------9s of %s of %-5s", "for", "the", "goooood", "aaall", "us")); PRINTF(("%--4.1s %s %------------------9.3s of %s of %-5.7s", "for", "the", "goooood", "aaall", "us")); PRINTF(("%--.sp--.su kkkk", "pegadinha po")); PRINTF(("%-9sScience!", "-42")); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_P && test_cat & CAT_BONUS_1) : 1; describe("\n%p, widths and -"); PRINTF(("that's the way it %-20pis", "")); PRINTF(("as soon as %-10possible", (void *) -1)); PRINTF(("as soon as %-16peasible", (void *) (((long int)3 << 42) + 15))); PRINTF(("as soon as %-16peasible", (void *) (((long int)3 << 42) + 15))); PRINTF(("thats %-psrobably not a good idea", (void *) 13)); PRINTF(("%------21pwhoa wtf is that", (void *) 13)); PRINTF(("%------21p yeah i'm %p running out %--p of ideas", (void *) 13, (void *) 65, (void *) -1)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_D && test_cat & CAT_BONUS_1) : 1; describe("\n%d, widths, precisions and -"); PRINTF(("%-d", 0)); PRINTF(("%-d", 1)); PRINTF(("%-d", 10)); PRINTF(("%-d", -10)); PRINTF(("%-d", 5000)); PRINTF(("%-d", -5000)); PRINTF(("%-d", (int)-2147483648)); PRINTF(("%-d", 2147483647)); PRINTF(("%-1d", 0)); PRINTF(("%-1d", 1)); PRINTF(("%-1d", 10)); PRINTF(("%-1d", -10)); PRINTF(("%-1d", 5000)); PRINTF(("%-1d", -5000)); PRINTF(("%-1d", (int)-2147483648)); PRINTF(("%-1d", 2147483647)); PRINTF(("%-10d", 0)); PRINTF(("%-10d", 1)); PRINTF(("%-10d", 10)); PRINTF(("%-10d", -10)); PRINTF(("%-10d", 5000)); PRINTF(("%-10d", -5000)); PRINTF(("%-10d", (int)-2147483648)); PRINTF(("%-10d", 2147483647)); PRINTF(("%-.d", 0)); PRINTF(("%-.1d", 1)); PRINTF(("%-.2d", 10)); PRINTF(("%-.3d", -10)); PRINTF(("%-.4d", 5000)); PRINTF(("%-.5d", -5000)); PRINTF(("%-.6d", (int)-2147483648)); PRINTF(("%-.7d", 2147483647)); PRINTF(("%-1.8d", 0)); PRINTF(("%-1.9d", 1)); PRINTF(("%-1.10d", 10)); PRINTF(("%-1.0d", -10)); PRINTF(("%-1.6d", 5000)); PRINTF(("%-1.4d", -5000)); PRINTF(("%-1.10d", (int)-2147483648)); PRINTF(("%-1.12d", 2147483647)); PRINTF(("%-10.d", 0)); PRINTF(("%-10.10d", 1)); PRINTF(("%-10.5d", 10)); PRINTF(("%-10.2d", -10)); PRINTF(("%-10.5d", 5000)); PRINTF(("%-10.5d", -5000)); PRINTF(("%-10.15d", (int)-2147483648)); PRINTF(("%-10.5d", 2147483647)); PRINTF(("%-15.d", 0)); PRINTF(("%-15.10d", 1)); PRINTF(("%-15.5d", 10)); PRINTF(("%-15.2d", -10)); PRINTF(("%-15.5d", 5000)); PRINTF(("%-15.5d", -5000)); PRINTF(("%-15.15d", (int)-2147483648)); PRINTF(("%-15.5d", 2147483647)); PRINTF(("%-4.5d%d%4d%-10d-d5%-.3d", 3, 4, 5, 6, 7)); PRINTF(("%-4.5d%d%4d%-10d-d5%-.3d", 300000, 400000, 500000, 600000, 700000)); PRINTF(("%-4.5d%d%4d%-10d-d5%-.3d", -300000, -400000, -500000, -600000, -700000)); PRINTF(("%-4.5d%d%4d%-10d-d5%-.3d", 2147483647, 2141483647, 2141483647, 2141483647, 2141483647)); PRINTF(("%-4.5d%d%4d%-10d-d5%-.3d", (int)-2147483648, (int)-2141483648, (int)-2141483648, (int)-2141483648, (int)-2141483648)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_I && test_cat & CAT_BONUS_1) : 1; describe("\n%i, widths, precisions and -"); PRINTF(("%-i", 0)); PRINTF(("%-i", 1)); PRINTF(("%-i", 10)); PRINTF(("%-i", -10)); PRINTF(("%-i", 5000)); PRINTF(("%-i", -5000)); PRINTF(("%-i", (int)-2147483648)); PRINTF(("%-i", 2147483647)); PRINTF(("%-1i", 0)); PRINTF(("%-1i", 1)); PRINTF(("%-1i", 10)); PRINTF(("%-1i", -10)); PRINTF(("%-1i", 5000)); PRINTF(("%-1i", -5000)); PRINTF(("%-1i", (int)-2147483648)); PRINTF(("%-1i", 2147483647)); PRINTF(("%-10i", 0)); PRINTF(("%-10i", 1)); PRINTF(("%-10i", 10)); PRINTF(("%-10i", -10)); PRINTF(("%-10i", 5000)); PRINTF(("%-10i", -5000)); PRINTF(("%-10i", (int)-2147483648)); PRINTF(("%-10i", 2147483647)); PRINTF(("%-.i", 0)); PRINTF(("%-.1i", 1)); PRINTF(("%-.2i", 10)); PRINTF(("%-.3i", -10)); PRINTF(("%-.4i", 5000)); PRINTF(("%-.5i", -5000)); PRINTF(("%-.6i", (int)-2147483648)); PRINTF(("%-.7i", 2147483647)); PRINTF(("%-1.8i", 0)); PRINTF(("%-1.9i", 1)); PRINTF(("%-1.10i", 10)); PRINTF(("%-1.0i", -10)); PRINTF(("%-1.6i", 5000)); PRINTF(("%-1.4i", -5000)); PRINTF(("%-1.10i", (int)-2147483648)); PRINTF(("%-1.12i", 2147483647)); PRINTF(("%-10.i", 0)); PRINTF(("%-10.10i", 1)); PRINTF(("%-10.5i", 10)); PRINTF(("%-10.2i", -10)); PRINTF(("%-10.5i", 5000)); PRINTF(("%-10.5i", -5000)); PRINTF(("%-10.15i", (int)-2147483648)); PRINTF(("%-10.5i", 2147483647)); PRINTF(("%-15.i", 0)); PRINTF(("%-15.10i", 1)); PRINTF(("%-15.5i", 10)); PRINTF(("%-15.2i", -10)); PRINTF(("%-15.5i", 5000)); PRINTF(("%-15.5i", -5000)); PRINTF(("%-15.15i", (int)-2147483648)); PRINTF(("%-15.5i", 2147483647)); PRINTF(("%-4.5i%i%4i%-10i-i5%-.3i", 3, 4, 5, 6, 7)); PRINTF(("%-4.5i%i%4i%-10i-i5%-.3i", 300000, 400000, 500000, 600000, 700000)); PRINTF(("%-4.5i%i%4i%-10i-i5%-.3i", -300000, -400000, -500000, -600000, -700000)); PRINTF(("%-4.5i%i%4i%-10i-i5%-.3i", 2147483647, 2141483647, 2141483647, 2141483647, 2141483647)); PRINTF(("%-4.5i%i%4i%-10i-i5%-.3i", (int)-2147483648, (int)-2141483648, (int)-2141483648, (int)-2141483648, (int)-2141483648)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_U && test_cat & CAT_BONUS_1) : 1; describe("\n%u, widths, precisions and -"); PRINTF(("%-u", 0)); PRINTF(("%-u", 1)); PRINTF(("%-u", 10)); PRINTF(("%-u", -10)); PRINTF(("%-u", 5000)); PRINTF(("%-u", -5000)); PRINTF(("%-u", (unsigned int)-1)); PRINTF(("%-u", 2147483647)); PRINTF(("%-1u", 0)); PRINTF(("%-1u", 1)); PRINTF(("%-1u", 10)); PRINTF(("%-1u", -10)); PRINTF(("%-1u", 5000)); PRINTF(("%-1u", -5000)); PRINTF(("%-1u", (unsigned int)-1)); PRINTF(("%-1u", 2147483647)); PRINTF(("%-10u", 0)); PRINTF(("%-10u", 1)); PRINTF(("%-10u", 10)); PRINTF(("%-10u", -10)); PRINTF(("%-10u", 5000)); PRINTF(("%-10u", -5000)); PRINTF(("%-10u", -1)); PRINTF(("%-10u", 2147483647)); PRINTF(("%-.u", 0)); PRINTF(("%-.1u", 1)); PRINTF(("%-.2u", 10)); PRINTF(("%-.3u", -10)); PRINTF(("%-.4u", 5000)); PRINTF(("%-.5u", -5000)); PRINTF(("%-.6u", -1)); PRINTF(("%-.7u", 2147483647)); PRINTF(("%-1.8u", 0)); PRINTF(("%-1.9u", 1)); PRINTF(("%-1.10u", 10)); PRINTF(("%-1.0u", -10)); PRINTF(("%-1.6u", 5000)); PRINTF(("%-1.4u", -5000)); PRINTF(("%-1.10u", -1)); PRINTF(("%-1.12u", 2147483647)); PRINTF(("%-10.u", 0)); PRINTF(("%-10.10u", 1)); PRINTF(("%-10.5u", 10)); PRINTF(("%-10.2u", -10)); PRINTF(("%-10.5u", 5000)); PRINTF(("%-10.5u", -5000)); PRINTF(("%-10.15u", -1)); PRINTF(("%-10.5u", 2147483647)); PRINTF(("%-15.u", 0)); PRINTF(("%-15.10u", 1)); PRINTF(("%-15.5u", 10)); PRINTF(("%-15.2u", -10)); PRINTF(("%-15.5u", 5000)); PRINTF(("%-15.5u", -5000)); PRINTF(("%-15.15u", -1)); PRINTF(("%-15.5u", 2147483647)); PRINTF(("%-4.5u%u%4u%-10u-u5%-.3u", 3, 4, 5, 6, 7)); PRINTF(("%-4.5u%u%4u%-10u-u5%-.3u", 300000, 400000, 500000, 600000, 700000)); PRINTF(("%-4.5u%u%4u%-10u-u5%-.3u", -300000, -400000, -500000, -600000, -700000)); PRINTF(("%-4.5u%u%4u%-10u-u5%-.3u", 2147483647, 2141483647, 2141483647, 2141483647, 2141483647)); PRINTF(("%-4.5u%u%4u%-10u-u5%-.3u", -1, -1, -1, -1, -1)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_X && test_cat & CAT_BONUS_1) : 1; describe("\n%x, widths, precisions and -"); PRINTF(("%-x", 0)); PRINTF(("%-x", 1)); PRINTF(("%-x", 10)); PRINTF(("%-x", -10)); PRINTF(("%-x", 5000)); PRINTF(("%-x", -5000)); PRINTF(("%-x", -1)); PRINTF(("%-x", 2147483647)); PRINTF(("%-1x", 0)); PRINTF(("%-1x", 1)); PRINTF(("%-1x", 10)); PRINTF(("%-1x", -10)); PRINTF(("%-1x", 5000)); PRINTF(("%-1x", -5000)); PRINTF(("%-1x", -1)); PRINTF(("%-1x", 2147483647)); PRINTF(("%-10x", 0)); PRINTF(("%-10x", 1)); PRINTF(("%-10x", 10)); PRINTF(("%-10x", -10)); PRINTF(("%-10x", 5000)); PRINTF(("%-10x", -5000)); PRINTF(("%-10x", -1)); PRINTF(("%-10x", 2147483647)); PRINTF(("%-.x", 0)); PRINTF(("%-.1x", 1)); PRINTF(("%-.2x", 10)); PRINTF(("%-.3x", -10)); PRINTF(("%-.4x", 5000)); PRINTF(("%-.5x", -5000)); PRINTF(("%-.6x", -1)); PRINTF(("%-.7x", 2147483647)); PRINTF(("%-1.8x", 0)); PRINTF(("%-1.9x", 1)); PRINTF(("%-1.10x", 10)); PRINTF(("%-1.0x", -10)); PRINTF(("%-1.6x", 5000)); PRINTF(("%-1.4x", -5000)); PRINTF(("%-1.10x", -1)); PRINTF(("%-1.12x", 2147483647)); PRINTF(("%-10.x", 0)); PRINTF(("%-10.10x", 1)); PRINTF(("%-10.5x", 10)); PRINTF(("%-10.2x", -10)); PRINTF(("%-10.5x", 5000)); PRINTF(("%-10.5x", -5000)); PRINTF(("%-10.15x", -1)); PRINTF(("%-10.5x", 2147483647)); PRINTF(("%-15.x", 0)); PRINTF(("%-15.10x", 1)); PRINTF(("%-15.5x", 10)); PRINTF(("%-15.2x", -10)); PRINTF(("%-15.5x", 5000)); PRINTF(("%-15.5x", -5000)); PRINTF(("%-15.15x", -1)); PRINTF(("%-15.5x", 2147483647)); PRINTF(("%-4.5x%x%4x%-10x-x5%-.3x", 3, 4, 5, 6, 7)); PRINTF(("%-4.5x%x%4x%-10x-x5%-.3x", 300000, 400000, 500000, 600000, 700000)); PRINTF(("%-4.5x%x%4x%-10x-x5%-.3x", -300000, -400000, -500000, -600000, -700000)); PRINTF(("%-4.5x%x%4x%-10x-x5%-.3x", 2147483647, 2141483647, 2141483647, 2141483647, 2141483647)); PRINTF(("%-4.5x%x%4x%-10x-x5%-.3x", -1, -1, -1, -1, -1)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_BIG_X && test_cat & CAT_BONUS_1) : 1; describe("\n%X, widths, precisions and -"); PRINTF(("%-X", 0)); PRINTF(("%-X", 1)); PRINTF(("%-X", 10)); PRINTF(("%-X", -10)); PRINTF(("%-X", 5000)); PRINTF(("%-X", -5000)); PRINTF(("%-X", -1)); PRINTF(("%-X", 2147483647)); PRINTF(("%-1X", 0)); PRINTF(("%-1X", 1)); PRINTF(("%-1X", 10)); PRINTF(("%-1X", -10)); PRINTF(("%-1X", 5000)); PRINTF(("%-1X", -5000)); PRINTF(("%-1X", -1)); PRINTF(("%-1X", 2147483647)); PRINTF(("%-10X", 0)); PRINTF(("%-10X", 1)); PRINTF(("%-10X", 10)); PRINTF(("%-10X", -10)); PRINTF(("%-10X", 5000)); PRINTF(("%-10X", -5000)); PRINTF(("%-10X", -1)); PRINTF(("%-10X", 2147483647)); PRINTF(("%-.X", 0)); PRINTF(("%-.1X", 1)); PRINTF(("%-.2X", 10)); PRINTF(("%-.3X", -10)); PRINTF(("%-.4X", 5000)); PRINTF(("%-.5X", -5000)); PRINTF(("%-.6X", -1)); PRINTF(("%-.7X", 2147483647)); PRINTF(("%-1.8X", 0)); PRINTF(("%-1.9X", 1)); PRINTF(("%-1.10X", 10)); PRINTF(("%-1.0X", -10)); PRINTF(("%-1.6X", 5000)); PRINTF(("%-1.4X", -5000)); PRINTF(("%-1.10X", -1)); PRINTF(("%-1.12X", 2147483647)); PRINTF(("%-10.X", 0)); PRINTF(("%-10.10X", 1)); PRINTF(("%-10.5X", 10)); PRINTF(("%-10.2X", -10)); PRINTF(("%-10.5X", 5000)); PRINTF(("%-10.5X", -5000)); PRINTF(("%-10.15X", -1)); PRINTF(("%-10.5X", 2147483647)); PRINTF(("%-15.X", 0)); PRINTF(("%-15.10X", 1)); PRINTF(("%-15.5X", 10)); PRINTF(("%-15.2X", -10)); PRINTF(("%-15.5X", 5000)); PRINTF(("%-15.5X", -5000)); PRINTF(("%-15.15X", -1)); PRINTF(("%-15.5X", 2147483647)); PRINTF(("%-4.5X%X%4X%-10X-X5%-.3X", 3, 4, 5, 6, 7)); PRINTF(("%-4.5X%X%4X%-10X-X5%-.3X", 300000, 400000, 500000, 600000, 700000)); PRINTF(("%-4.5X%X%4X%-10X-X5%-.3X", -300000, -400000, -500000, -600000, -700000)); PRINTF(("%-4.5X%X%4X%-10X-X5%-.3X", 2147483647, 2141483647, 2141483647, 2141483647, 2141483647)); PRINTF(("%-4.5X%X%4X%-10X-X5%-.3X", -1, -1, -1, -1, -1)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_D && test_cat & CAT_BONUS_1) : 1; describe("\n%d, widths, precisions and 0"); PRINTF(("%01d", 0)); PRINTF(("%01d", -4)); PRINTF(("%010d", 42)); PRINTF(("%042d", 42000)); PRINTF(("%020d", -42000)); PRINTF(("wait for it... %050d", 42)); PRINTF(("%020d is how many tests are going to be made", 8000)); PRINTF(("%05d", 2147483647)); PRINTF(("%030d", 2147483647)); PRINTF(("%010d", 2147483647)); PRINTF(("%05d", (int)-2147483648)); PRINTF(("%030d", (int)-2147483648)); PRINTF(("%010d", (int)-2147483648)); PRINTF(("%011d", (int)-2147483648)); PRINTF(("%012d", (int)-2147483648)); PRINTF(("%012d, %20d, %2d, %42d", (int)-2147483648, 3, 30, -1)); PRINTF(("%012d, %d, %2d, %42d", (int)-2147483648, 3, 30, -1)); PRINTF(("%014d%020d%02d%0d", (int)-2147483648, 3, 30, -1)); PRINTF(("%014dc%020ds%02dx%0du", (int)-2147483648, 3, 30, -1)); PRINTF(("%01.d", 0)); PRINTF(("%01.0d", 0)); PRINTF(("%02.0d", 0)); PRINTF(("%03.0d", 0)); PRINTF(("%01.1d", 0)); PRINTF(("%01.2d", 0)); PRINTF(("%01.3d", 0)); PRINTF(("%01.0d", -4)); PRINTF(("%01.1d", -4)); PRINTF(("%01.2d", -4)); PRINTF(("%01.3d", -4)); PRINTF(("%01.0d", 4)); PRINTF(("%01.1d", 4)); PRINTF(("%01.2d", 4)); PRINTF(("%01.3d", 4)); PRINTF(("%010.20d", 42)); PRINTF(("%042.2d", 42000)); PRINTF(("%042.20d", 42000)); PRINTF(("%042.42d", 42000)); PRINTF(("%042.52d", 42000)); PRINTF(("%020.10d", -42000)); PRINTF(("%020.20d", -42000)); PRINTF(("%020.30d", -42000)); PRINTF(("wait for it... %050.50d", 42)); PRINTF(("%020.19d is how many tests are going to be made", 8000)); PRINTF(("%020.20d is how many tests are going to be made", 8000)); PRINTF(("%020.21d is how many tests are going to be made", 8000)); PRINTF(("%05d", 2147483647)); PRINTF(("%030d", 2147483647)); PRINTF(("%09d", 2147483647)); PRINTF(("%010d", 2147483647)); PRINTF(("%011d", 2147483647)); PRINTF(("%05d", (int)-2147483648)); PRINTF(("%030d", (int)-2147483648)); PRINTF(("%010d", (int)-2147483648)); PRINTF(("%011d", (int)-2147483648)); PRINTF(("%012d", (int)-2147483648)); PRINTF(("%012d, %20d, %2d, %000042d", (int)-2147483648, 3, 30, -1)); PRINTF(("%012d, %d, %002d, %42d", (int)-2147483648, 3, 30, -1)); PRINTF(("%0014.2d%020d%0002.d%000.5d", (int)-2147483648, 3, 30, -1)); PRINTF(("%014dc%020ds%02dx%0du", (int)-2147483648, 3, 30, -1)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_I && test_cat & CAT_BONUS_1) : 1; describe("\n%i, widths, precisions and 0"); PRINTF(("%01i", 0)); PRINTF(("%01i", -4)); PRINTF(("%010i", 42)); PRINTF(("%042i", 42000)); PRINTF(("%020i", -42000)); PRINTF(("wait for it... %050i", 42)); PRINTF(("%020i is how many tests are going to be maie", 8000)); PRINTF(("%05i", 2147483647)); PRINTF(("%030i", 2147483647)); PRINTF(("%010i", 2147483647)); PRINTF(("%05i", (int)-2147483648)); PRINTF(("%030i", (int)-2147483648)); PRINTF(("%010i", (int)-2147483648)); PRINTF(("%011i", (int)-2147483648)); PRINTF(("%012i", (int)-2147483648)); PRINTF(("%012i, %20i, %2i, %42i", (int)-2147483648, 3, 30, -1)); PRINTF(("%012i, %i, %2i, %42i", (int)-2147483648, 3, 30, -1)); PRINTF(("%014i%020i%02i%0i", (int)-2147483648, 3, 30, -1)); PRINTF(("%014ic%020is%02ix%0iu", (int)-2147483648, 3, 30, -1)); PRINTF(("%01.i", 0)); PRINTF(("%01.0i", 0)); PRINTF(("%02.0i", 0)); PRINTF(("%03.0i", 0)); PRINTF(("%01.1i", 0)); PRINTF(("%01.2i", 0)); PRINTF(("%01.3i", 0)); PRINTF(("%01.0i", -4)); PRINTF(("%01.1i", -4)); PRINTF(("%01.2i", -4)); PRINTF(("%01.3i", -4)); PRINTF(("%01.0i", 4)); PRINTF(("%01.1i", 4)); PRINTF(("%01.2i", 4)); PRINTF(("%01.3i", 4)); PRINTF(("%010.20i", 42)); PRINTF(("%042.2i", 42000)); PRINTF(("%042.20i", 42000)); PRINTF(("%042.42i", 42000)); PRINTF(("%042.52i", 42000)); PRINTF(("%020.10i", -42000)); PRINTF(("%020.20i", -42000)); PRINTF(("%020.30i", -42000)); PRINTF(("wait for it... %050.50i", 42)); PRINTF(("%020.19i is how many tests are going to be made", 8000)); PRINTF(("%020.20i is how many tests are going to be made", 8000)); PRINTF(("%020.21i is how many tests are going to be made", 8000)); PRINTF(("%05i", 2147483647)); PRINTF(("%030i", 2147483647)); PRINTF(("%09i", 2147483647)); PRINTF(("%010i", 2147483647)); PRINTF(("%011i", 2147483647)); PRINTF(("%05i", (int)-2147483648)); PRINTF(("%030i", (int)-2147483648)); PRINTF(("%010i", (int)-2147483648)); PRINTF(("%011i", (int)-2147483648)); PRINTF(("%012i", (int)-2147483648)); PRINTF(("%012i, %20i, %2i, %000042i", (int)-2147483648, 3, 30, -1)); PRINTF(("%012i, %i, %002i, %42i", (int)-2147483648, 3, 30, -1)); PRINTF(("%0014.2i%020i%0002.i%000.5i", (int)-2147483648, 3, 30, -1)); PRINTF(("%014ic%020is%02ix%0iu", (int)-2147483648, 3, 30, -1)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_U && test_cat & CAT_BONUS_1) : 1; describe("\n%u, widths, precisions and 0"); PRINTF(("%01u", 0)); PRINTF(("%01u", -4)); PRINTF(("%010u", 42)); PRINTF(("%042u", 42000)); PRINTF(("%020u", -42000)); PRINTF(("wait for it... %050u", 42)); PRINTF(("%020u is how many tests are going to be maie", 8000)); PRINTF(("%05u", 2147483647)); PRINTF(("%030u", 2147483647)); PRINTF(("%010u", 2147483647)); PRINTF(("%05u", -1)); PRINTF(("%030u", -1)); PRINTF(("%010u", -1)); PRINTF(("%011u", -1)); PRINTF(("%012u", -1)); PRINTF(("%012u, %20u, %2u, %42u", -1, 3, 30, -1)); PRINTF(("%012u, %u, %2u, %42u", -1, 3, 30, -1)); PRINTF(("%014u%020u%02u%0u", -1, 3, 30, -1)); PRINTF(("%014uc%020us%02ux%0ui", -1, 3, 30, -1)); PRINTF(("%01.u", 0)); PRINTF(("%01.0u", 0)); PRINTF(("%02.0u", 0)); PRINTF(("%03.0u", 0)); PRINTF(("%01.1u", 0)); PRINTF(("%01.2u", 0)); PRINTF(("%01.3u", 0)); PRINTF(("%01.0u", 4)); PRINTF(("%01.1u", 4)); PRINTF(("%01.2u", 4)); PRINTF(("%01.3u", 4)); PRINTF(("%010.20u", 42)); PRINTF(("%042.2u", 42000)); PRINTF(("%042.20u", 42000)); PRINTF(("%042.42u", 42000)); PRINTF(("%042.52u", 42000)); PRINTF(("wait for it... %050.50u", 42)); PRINTF(("%020.19u is how many tests are going to be made", 8000)); PRINTF(("%020.20u is how many tests are going to be made", 8000)); PRINTF(("%020.21u is how many tests are going to be made", 8000)); PRINTF(("%05u", 2147483647)); PRINTF(("%030u", 2147483647)); PRINTF(("%09u", 2147483647)); PRINTF(("%010u", 2147483647)); PRINTF(("%011u", 2147483647)); PRINTF(("%05u", -1)); PRINTF(("%030u", -1)); PRINTF(("%010u", -1)); PRINTF(("%011u", -1)); PRINTF(("%012u", -1)); PRINTF(("%012u, %20u, %2u, %000042u", -1, 3, 30, -1)); PRINTF(("%012u, %u, %002u, %42u", -1, 3, 30, -1)); PRINTF(("%0014.2u%020u%0002.u%000.5u", -1, 3, 30, -1)); PRINTF(("%014uc%020us%02ux%0ui", -1, 3, 30, -1)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_X && test_cat & CAT_BONUS_1) : 1; describe("\n%x, widths, precisions and 0"); PRINTF(("%01x", 0)); PRINTF(("%01x", -4)); PRINTF(("%010x", 42)); PRINTF(("%042x", 42000)); PRINTF(("%020x", -42000)); PRINTF(("wait for it... %050x", 42)); PRINTF(("%020x is how many tests are going to be made", 8000)); PRINTF(("%05x", 2147483647)); PRINTF(("%030x", 2147483647)); PRINTF(("%010x", 2147483647)); PRINTF(("%05x", -1)); PRINTF(("%030x", -1)); PRINTF(("%010x", -1)); PRINTF(("%011x", -1)); PRINTF(("%012x", -1)); PRINTF(("%012x, %20x, %2x, %42x", -1, 3, 30, -1)); PRINTF(("%012x, %x, %2x, %42x", -1, 3, 30, -1)); PRINTF(("%014x%020x%02x%0x", -1, 3, 30, -1)); PRINTF(("%014xc%020xs%02xX%0xi", -1, 3, 30, -1)); PRINTF(("%01.x", 0)); PRINTF(("%01.0x", 0)); PRINTF(("%02.0x", 0)); PRINTF(("%03.0x", 0)); PRINTF(("%01.1x", 0)); PRINTF(("%01.2x", 0)); PRINTF(("%01.3x", 0)); PRINTF(("%01.0x", 4)); PRINTF(("%01.1x", 4)); PRINTF(("%01.2x", 4)); PRINTF(("%01.3x", 4)); PRINTF(("%010.20x", 42)); PRINTF(("%042.2x", 42000)); PRINTF(("%042.20x", 42000)); PRINTF(("%042.42x", 42000)); PRINTF(("%042.52x", 42000)); PRINTF(("wait for it... %050.50x", 42)); PRINTF(("%020.19x is how many tests are going to be made", 8000)); PRINTF(("%020.20x is how many tests are going to be made", 8000)); PRINTF(("%020.21x is how many tests are going to be made", 8000)); PRINTF(("%05x", 2147483647)); PRINTF(("%030x", 2147483647)); PRINTF(("%09x", 2147483647)); PRINTF(("%010x", 2147483647)); PRINTF(("%011x", 2147483647)); PRINTF(("%05x", -1)); PRINTF(("%030x", -1)); PRINTF(("%010x", -1)); PRINTF(("%011x", -1)); PRINTF(("%012x", -1)); PRINTF(("%012x, %20x, %2x, %000042x", -1, 3, 30, -1)); PRINTF(("%012x, %x, %002x, %42x", -1, 3, 30, -1)); PRINTF(("%0014.2x%020x%0002.x%000.5x", -1, 3, 30, -1)); PRINTF(("%014xc%020xs%02xx%0xi", -1, 3, 30, -1)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_BIG_X && test_cat & CAT_BONUS_1) : 1; describe("\n%X, widths, precisions and 0"); PRINTF(("%01X", 0)); PRINTF(("%01X", -4)); PRINTF(("%010X", 42)); PRINTF(("%042X", 42000)); PRINTF(("%020X", -42000)); PRINTF(("wait for it... %050X", 42)); PRINTF(("%020X is how many tests are going to be made", 8000)); PRINTF(("%05X", 2147483647)); PRINTF(("%030X", 2147483647)); PRINTF(("%010X", 2147483647)); PRINTF(("%05X", -1)); PRINTF(("%030X", -1)); PRINTF(("%010X", -1)); PRINTF(("%011X", -1)); PRINTF(("%012X", -1)); PRINTF(("%012X, %20X, %2X, %42X", -1, 3, 30, -1)); PRINTF(("%012X, %X, %2X, %42X", -1, 3, 30, -1)); PRINTF(("%014X%020X%02X%0X", -1, 3, 30, -1)); PRINTF(("%014Xc%020Xs%02XX%0Xi", -1, 3, 30, -1)); PRINTF(("%01.X", 0)); PRINTF(("%01.0X", 0)); PRINTF(("%02.0X", 0)); PRINTF(("%03.0X", 0)); PRINTF(("%01.1X", 0)); PRINTF(("%01.2X", 0)); PRINTF(("%01.3X", 0)); PRINTF(("%01.0X", 4)); PRINTF(("%01.1X", 4)); PRINTF(("%01.3X", 4)); PRINTF(("%010.20X", 42)); PRINTF(("%042.2X", 42000)); PRINTF(("%042.20X", 42000)); PRINTF(("%042.42X", 42000)); PRINTF(("%042.52X", 42000)); PRINTF(("wait for it... %050.50X", 42)); PRINTF(("%020.19X is how many tests are going to be made", 8000)); PRINTF(("%020.20X is how many tests are going to be made", 8000)); PRINTF(("%020.21X is how many tests are going to be made", 8000)); PRINTF(("%05X", 2147483647)); PRINTF(("%030X", 2147483647)); PRINTF(("%09X", 2147483647)); PRINTF(("%010X", 2147483647)); PRINTF(("%011X", 2147483647)); PRINTF(("%05X", -1)); PRINTF(("%030.20X", -1)); PRINTF(("%010.11X", -1)); PRINTF(("%011.11X", -1)); PRINTF(("%012.11X", -1)); PRINTF(("%012X, %20X, %2X, %000042.20X", -1, 3, 30, -1)); PRINTF(("%012X, %X, %002X, %42.5X", -1, 3, 30, -1)); PRINTF(("%0014.2X%020X%0002.X%000.5X", -1, 3, 30, -1)); PRINTF(("%014Xc%020Xs%02.5XX%0.Xi", -1, 3, 30, -1)); right_cat = (g_all_bonus & CAT_BONUS_2) ? 1 : test_cat ? (test_cat & CAT_X && test_cat & CAT_BONUS_2) : 1; describe("\n%x and #"); PRINTF(("%#x", 0)); PRINTF(("%#x", -4)); PRINTF(("%#x", 42)); PRINTF(("%#x", 42000)); PRINTF(("%#x", -42000)); PRINTF(("wait for it... %#x", 42)); PRINTF(("%#x is how many tests are going to be made", 8000)); PRINTF(("%#xd", 2147483647)); PRINTF(("%#xp", 2147483647)); PRINTF(("%#xX", 2147483647)); PRINTF(("%#xp", -1)); PRINTF(("%#xd", -1)); PRINTF(("%#xX", -1)); PRINTF(("%#x", -1)); PRINTF(("%#x, %x, %x, %x", -1, 3, 30, -1)); PRINTF(("%#x%#x%#x%#x", -1, 3, 30, -1)); PRINTF(("%#xc%#xs%#xX%#xi", -1, 3, 30, -1)); PRINTF(("--.%#xp", 0)); PRINTF(("--.%#xs", 0)); PRINTF(("%#xc", 4)); PRINTF(("c%#x-i", 42000)); PRINTF(("wait for it... %#xp", 42)); right_cat = (g_all_bonus & CAT_BONUS_2) ? 1 : test_cat ? (test_cat & CAT_BIG_X && test_cat & CAT_BONUS_2) : 1; describe("\n%X and #"); PRINTF(("%#X", 0)); PRINTF(("%#X", -4)); PRINTF(("%#X", 42)); PRINTF(("%#X", 42000)); PRINTF(("%#X", -42000)); PRINTF(("wait for it... %#X", 42)); PRINTF(("%#X is how many tests are going to be made", 8000)); PRINTF(("%#Xd", 2147483647)); PRINTF(("%#Xp", 2147483647)); PRINTF(("%#XX", 2147483647)); PRINTF(("%#Xp", -1)); PRINTF(("%#Xd", -1)); PRINTF(("%#XX", -1)); PRINTF(("%#X", -1)); PRINTF(("%#X, %X, %X, %X", -1, 3, 30, -1)); PRINTF(("%#X%#X%#X%#X", -1, 3, 30, -1)); PRINTF(("%#Xc%#Xs%#Xx%#Xi", -1, 3, 30, -1)); PRINTF(("--.%#Xp", 0)); PRINTF(("--.%#Xs", 0)); PRINTF(("%#Xc", 4)); PRINTF(("c%#X-i", 42000)); PRINTF(("wait for it... %#Xp", 42)); right_cat = (g_all_bonus & CAT_BONUS_2) ? 1 : test_cat ? (test_cat & CAT_D && test_cat & CAT_BONUS_2) : 1; describe("\n%d and ' '"); PRINTF(("% d", 0)); PRINTF(("% d", 1)); PRINTF(("% d", -1)); PRINTF(("% d", 0)); PRINTF(("% d", 1)); PRINTF(("% d", -1)); PRINTF(("% d", 2147483647)); PRINTF(("% d", (int)-2147483648)); PRINTF(("% d", 2147483647)); PRINTF(("% d", (int)-2147483648)); PRINTF(("% d", 2178647)); PRINTF(("% d", (int)-2144348)); PRINTF(("% d", 2147837)); PRINTF(("% d", (int)-2147486)); PRINTF(("% d this is %d getting% di hard :/", (int)-2147486, -2, 42)); right_cat = (g_all_bonus & CAT_BONUS_2) ? 1 : test_cat ? (test_cat & CAT_I && test_cat & CAT_BONUS_2) : 1; describe("\n%i and ' '"); PRINTF(("% i", 0)); PRINTF(("% i", 2)); PRINTF(("% i", -2)); PRINTF(("% i", 0)); PRINTF(("% i", 1)); PRINTF(("% i", -1)); PRINTF(("% i", 2147483647)); PRINTF(("% i", (int)-2147483648)); PRINTF(("% i", 2147483647)); PRINTF(("% i", (int)-2147483648)); PRINTF(("% i", 2178647)); PRINTF(("% i", (int)-2144348)); PRINTF(("% i", 2147837)); PRINTF(("% i", (int)-2147486)); PRINTF(("% i this is %i getting% is hari :/", (int)-2147486, -2, 42)); right_cat = (g_all_bonus & CAT_BONUS_2) ? 1 : test_cat ? (test_cat & CAT_D && test_cat & CAT_BONUS_2) : 1; describe("\n%d and +"); PRINTF(("%+d", 0)); PRINTF(("%+d", 1)); PRINTF(("%+d", -1)); PRINTF(("%+d", 24)); PRINTF(("%+d", 42)); PRINTF(("%+d", -42)); PRINTF(("%+d", 2147483647)); PRINTF(("%+d", (int)-2147483648)); PRINTF(("%+++d", 2147483647)); PRINTF(("%++d", (int)-2147483648)); PRINTF(("%+d", 2178647)); PRINTF(("%+d", (int)-2144348)); PRINTF(("%+++d", 2147837)); PRINTF(("%++d", (int)-2147486)); PRINTF(("%++d this is %d getting%+di hard :/", (int)-2147486, -2, 42)); right_cat = (g_all_bonus & CAT_BONUS_2) ? 1 : test_cat ? (test_cat & CAT_I && test_cat & CAT_BONUS_2) : 1; describe("\n%d and +"); PRINTF(("%+i", 0)); PRINTF(("%+i", 1)); PRINTF(("%+i", -1)); PRINTF(("%+i", 24)); PRINTF(("%+i", 42)); PRINTF(("%+i", -42)); PRINTF(("%+i", 2147483647)); PRINTF(("%+i", (int)-2147483648)); PRINTF(("%+++i", 2147483647)); PRINTF(("%++i", (int)-2147483648)); PRINTF(("%+i", 2178647)); PRINTF(("%+i", (int)-2144348)); PRINTF(("%+++i", 2147837)); PRINTF(("%++i", (int)-2147486)); PRINTF(("%++i this is %i getting%+ix hard :/", (int)-2147486, -2, 42)); return (0); } ================================================ FILE: src/tests.c.old ================================================ #include "ft_printf_tester.h" #include "helpers.h" #include "libftprintf.h" #define INT_MIN (int)-2141483648 #define INT_MAX 2141483647 extern char g_orig_fake_stdout[BUFSIZ]; extern char g_user_fake_stdout[BUFSIZ]; extern char *g_test_params; extern int g_test_nbr; extern int already_printed_help; extern int g_current_test; extern int g_all_bonus; int right_cat = 1; int run_tests(int test_cat) { int wstatus; char *null_str = NULL; int should_run = 1; describe("basic test"); PRINTF(("1, 2, 3, -d test, testing, 0.4s sound, 1, 2, 3xp, sound, -*dtest")); // if no cateogry was specified, then run all of the categories right_cat = test_cat ? test_cat & (CAT_C | CAT_MANDATORY) : 1; describe("\n%c basic"); PRINTF(("%c", 'a')); PRINTF(("%c%c%c*", '\0', '1', 1)); PRINTF(("%c small string", 'a')); PRINTF(("%c small string", '\0')); PRINTF(("the char is: %c", 'a')); PRINTF(("the char is: %c", '\0')); PRINTF(("n%cs", 'a')); PRINTF(("%c%c%c%c%c", 'a', 'i', 'u', 'e', 'o')); PRINTF(("l%cl%cl%cl%cl%c", 'a', 'i', 'u', 'e', 'o')); PRINTF(("l%cl%cl%cl%cl%c", '\0', '\0', '\0', 'e', '\0')); right_cat = test_cat ? test_cat & (CAT_S | CAT_MANDATORY) : 1; describe("\n%s basic"); PRINTF(("%s", "")); PRINTF(("this is a %s", "test")); PRINTF(("this is 1 %s with %s %s", "test", "multiple", "strings")); PRINTF(("%s%s%s%s", "This ", "is", " an ugly ", "test")); PRINTF(("%s", "This is a rather simple test.")); PRINTF(("%s", "-2")); PRINTF((" test with %s some %s empty strings", "", "")) PRINTF(("%s", "-24")); PRINTF(("%s", "-stop")); PRINTF(("%s", "-0003")); PRINTF(("%s", "000-0003")); PRINTF(("%s", "0x42")); PRINTF(("%s", "0x0000042")); PRINTF(("some naugty tests: %s", "0000%")); PRINTF(("some naugty tests: %s", " %")); PRINTF(("some naugty tests: %s", "%000")); PRINTF(("%s", null_str)); PRINTF(("%s everywhere", null_str)); PRINTF(("everywhere %s", null_str)); PRINTF(("%s", "h")); PRINTF(("t%st%s", "a", "u")); PRINTF(("%s%s%s%s%s%s", "a", "i", "u", "e", "o", "l")); right_cat = test_cat ? test_cat & (CAT_P | CAT_MANDATORY) : 1; describe("\n%p basic"); int test = 42; PRINTF(("%p", &test)); PRINTF(("%p is a virtual memory address", &test)); PRINTF(("The address of the answer is %p", &test)); PRINTF(("The address is %p, so what?", &test)); int *ptr = &test; PRINTF(("A pointer at %p points to %p", &test, &ptr)); PRINTF(("This %p is a very strange address", (void *)(long int)test)); char *mallocked = malloc(2); PRINTF(("This %p is an address from the heap", mallocked); free(mallocked);); free(mallocked); PRINTF_EXPECTED(("%p", NULL), /* expected: */ ("0x0")); PRINTF_EXPECTED(("The NULL macro represents the %p address", NULL), ("The NULL macro represents the 0x0 address")); PRINTF(("This %p is even stranger", (void *)-1)); right_cat = test_cat ? test_cat & (CAT_D | CAT_MANDATORY) : 1; describe("\n%d basic"); PRINTF(("%d", 0)); PRINTF(("%d", 10)); PRINTF(("%d, %d", 10, 20)); PRINTF(("%d%d%d%d", 10, 20, 30, 5)); PRINTF(("%d %d", 2147483647, (int)-2147483648)); PRINTF(("42 - 84 is %d", -42)); PRINTF(("%d C is the lowest temperature in the universe", -273)); PRINTF(("%dxC is the lowest temperature in the universe", -273)); PRINTF(("%dsC is the lowest temperature in the universe", -273)); PRINTF(("%dpC is the lowest temperature in the universe", -273)); right_cat = test_cat ? test_cat & (CAT_I | CAT_MANDATORY) : 1; describe("\n%i basic"); PRINTF(("%i", 0)); PRINTF(("%i", 10)); PRINTF(("%i, %i", 10, 23)); PRINTF(("%i%i%i%i%i%i%i", 10, 23, -2, 37, 200, -9999, 977779)); PRINTF(("%i %i", 2147483647, (int)-2147483648)); PRINTF(("%iq%i", 21447, -21648)); right_cat = test_cat ? test_cat & (CAT_U | CAT_MANDATORY) : 1; describe("\n%u basic"); PRINTF(("%u", 42)); PRINTF(("%u", 0)); PRINTF(("%u", 2147483647)); PRINTF(("%u", (unsigned int)2147483648)); PRINTF(("%u", (unsigned int)3147983649)); PRINTF(("%u", (unsigned int)4294967295)); PRINTF(("%u to the power of %u is %u", 2, 32, (unsigned int)4294967295)); PRINTF(("%u%u%u%u", (unsigned int)429896724, 0, 32, (unsigned int)4294967295)); right_cat = test_cat ? test_cat & (CAT_X | CAT_MANDATORY ) : 1; describe("\n%x basic"); PRINTF(("%x", 0)); PRINTF(("%x", 1)); PRINTF(("%x", 10)); PRINTF(("%x", 16)); PRINTF(("%x", 160)); PRINTF(("%x", 255)); PRINTF(("%x", 256)); PRINTF(("%x", (unsigned int)3735929054)); PRINTF(("the password is %x", (unsigned int)3735929054)); PRINTF(("%x is the definitive answer", (unsigned int)66)); PRINTF(("this is the real number: %x", (unsigned int)-1)); right_cat = test_cat ? test_cat & (CAT_BIG_X | CAT_MANDATORY ): 1; describe("\n%X basic"); PRINTF(("%X", 0)); PRINTF(("%X", 1)); PRINTF(("%X", 10)); PRINTF(("%X", 16)); PRINTF(("%X", 160)); PRINTF(("%X", 255)); PRINTF(("%X", 256)); PRINTF(("%X", (unsigned int)3735929054)); PRINTF(("the password is %X", (unsigned int)3735929054)); PRINTF(("%X is the definitive answer", (unsigned int)66)); PRINTF(("this is the real number: %X", (unsigned int)-1)); right_cat = test_cat ? test_cat & (CAT_PERCENT | CAT_MANDATORY) : 1; describe("\n%% basic"); PRINTF(("%%")); PRINTF(("100%%")); PRINTF(("%%p is how you print a pointer in printf")); PRINTF(("the '%%%%' is used to print a %% in printf")); PRINTF(("%%%%%%%%%%%%%%%%")); PRINTF(("%%c%%s%%p%%d%%i%%u%%x%%X%%")); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_C && test_cat & CAT_BONUS_1) : 1; describe("\n%c and widths"); PRINTF(("%1c", 'a')) PRINTF(("%1c", '\0')) PRINTF(("%10c", 'b')) PRINTF(("%10c", '\0')) PRINTF(("%2c", 'c')) PRINTF(("there are 15 spaces between this text and the next char%15c", 'd')) PRINTF(("%5chis paragraph is indented", 't')) PRINTF(("%5c now you see", '\0')) PRINTF(("The number %7c represents luck", '7')) right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_S && test_cat & CAT_BONUS_1) : 1; describe("\n%s and widths"); PRINTF(("%1s", "")); PRINTF(("%2s", "")); PRINTF(("%5s", "")); PRINTF(("%1s", "a")); PRINTF(("%1s", "abc")); PRINTF(("%7s", "a")); PRINTF(("%7s", "abc")); PRINTF(("%1s", "-42")); PRINTF(("%2s", "-42")); PRINTF(("%3s", "-42")); PRINTF(("%4s", "-42")); PRINTF(("%5s", "-42")); PRINTF(("%6s", "-42")); PRINTF(("%1s", null_str)); PRINTF(("%2s", null_str)); PRINTF(("%5s", null_str)); PRINTF(("%6s", null_str)); PRINTF(("%7s", null_str)); PRINTF(("%7s is as easy as %13s", "abc", "123")); PRINTF(("%13s are the three first letter of the %3s", "a, b and c", "alphabet")); PRINTF(("%s%13s%42s%3s", "a, b and c", " are letters", " of the", " alphabet")); PRINTF(("%sc%13sd%42sp%3sx", "a, b and c", " are letters", " of the", " alphabet")); PRINTF(("%sc%13sd%42sp%3sx", "a, b and c", " are letters", " of the", " alphabet")); PRINTF(("%sc%13sd%42sp%sx", "a, b and c", "", " of the", "")); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_P && test_cat & CAT_BONUS_1) : 1; describe("\n%p and widths"); char c; PRINTF(("%1p", &c)); PRINTF(("%30p", &c)); PRINTF(("%12p", (void *)0x7ffe6b8e60c6)); PRINTF(("%13p", (void *)0x7ffe6b8e60c5)); PRINTF(("%14p", (void *)0x7ffe6b8e60c4)); PRINTF(("the address is %12p", (void *)0x7ffe6b8e60c7)); PRINTF(("the address is %13p", (void *)0x7ffe6b8e60c8)); PRINTF(("the address is %14p", (void *)0x7ffe6b8e60c9)); PRINTF_EXPECTED(("the address is %1p", (void *)0), /* expected: */ ("the address is 0x0")); PRINTF_EXPECTED(("the address is %2p", (void *)0), /* expected: */ ("the address is 0x0")); PRINTF_EXPECTED(("the address is %3p", (void *)0), /* expected: */ ("the address is 0x0")); PRINTF_EXPECTED(("the address is %4p", (void *)0), /* expected: */ ("the address is 0x0")); PRINTF_EXPECTED(("the address is %8p", (void *)0), /* expected: */ ("the address is 0x0")); PRINTF(("%12p is the address", (void *)0x7ffe6b8e60c7)); PRINTF(("%13p is the address", (void *)0x7ffe6b8e60c8)); PRINTF(("%14p is the address", (void *)0x7ffe6b8e60c9)); PRINTF_EXPECTED(("%1p is the address", (void *)0), /* expected: */ ("0x0 is the address")); PRINTF_EXPECTED(("%2p is the address", (void *)0), /* expected: */ ("0x0 is the address")); PRINTF_EXPECTED(("%3p is the address", (void *)0), /* expected: */ ("0x0 is the address")); PRINTF_EXPECTED(("%4p is the address", (void *)0), /* expected: */ (" 0x0 is the address")); PRINTF_EXPECTED(("%8p is the address", (void *)0), /* expected: */ (" 0x0 is the address")); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_D && test_cat & CAT_BONUS_1) : 1; describe("\n%d and widths"); PRINTF(("%1d", 0)); PRINTF(("%1d", -4)); PRINTF(("%10d", 42)); PRINTF(("%42d", 42000)); PRINTF(("%20d", -42000)); PRINTF(("wait for it... %50d", 42)); PRINTF(("%20d is how many tests are going to be made", 8000)); PRINTF(("%5d", 2147483647)); PRINTF(("%30d", 2147483647)); PRINTF(("%10d", 2147483647)); PRINTF(("%5d", (int)-2147483648)); PRINTF(("%30d", (int)-2147483648)); PRINTF(("%10d", (int)-2147483648)); PRINTF(("%11d", (int)-2147483648)); PRINTF(("%12d", (int)-2147483648)); PRINTF(("%12d, %20d, %2d, %42d", (int)-2147483648, 3, 30, -1)); PRINTF(("%12d, %d, %2d, %42d", (int)-2147483648, 3, 30, -1)); PRINTF(("%14d%20d%2d%d", (int)-2147483648, 3, 30, -1)); PRINTF(("%14dc%20ds%2dx%du", (int)-2147483648, 3, 30, -1)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_I && test_cat & CAT_BONUS_1) : 1; describe("\n%i and widths"); PRINTF(("%1i", 0)); PRINTF(("%1i", -4)); PRINTF(("%10i", 42)); PRINTF(("%42i", 42000)); PRINTF(("%20i", -42000)); PRINTF(("wait for it... %50i", 42)); PRINTF(("%20i is how many tests are going to be made", 8000)); PRINTF(("%5i", 2147483647)); PRINTF(("%30i", 2147483647)); PRINTF(("%10i", 2147483647)); PRINTF(("%5i", (int)-2147483648)); PRINTF(("%30i", (int)-2147483648)); PRINTF(("%10i", (int)-2147483648)); PRINTF(("%11i", (int)-2147483648)); PRINTF(("%12i", (int)-2147483648)); PRINTF(("%12i, %20i, %2i, %42i", (int)-2147483648, 3, 30, -1)); PRINTF(("%12i, %i, %2i, %42i", (int)-2147483648, 3, 30, -1)); PRINTF(("%14i%20i%2i%i", (int)-2147483648, 3, 30, -1)); PRINTF(("%14ic%20is%2ix%du", (int)-2147483648, 3, 30, -1)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_U && test_cat & CAT_BONUS_1) : 1; describe("\n%u and widths"); PRINTF(("%1u", 0)); PRINTF(("%2u", 1)); PRINTF(("%1u", 1000)); PRINTF(("%4u", 1000)); PRINTF(("%30u", 1000)); PRINTF(("%9u is the biggest unsigned int", (unsigned int)-1)); PRINTF(("%10uis the biggest unsigned int", (unsigned int)-1)); PRINTF(("%11uis the biggest unsigned int", (unsigned int)-1)); PRINTF(("the biggest unsigned int is %9u", (unsigned int)-1)); PRINTF(("the biggest unsigned int is %10u", (unsigned int)-1)); PRINTF(("the biggest unsigned int is %11u", (unsigned int)-1)); PRINTF(("Here are some numbers: %1u%2u%5u%3u%9u and %ui", 11, (unsigned int)-1, 2, 200, 3, 10)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_X && test_cat & CAT_BONUS_1) : 1; describe("\n%x and widths"); PRINTF(("%1x", 0)); PRINTF(("%2x", 1)); PRINTF(("%3x", 10)); PRINTF(("%1x", 16)); PRINTF(("%2x", 160)); PRINTF(("%3x", 255)); PRINTF(("%42x", 256)); PRINTF(("%7x", (unsigned int)3735929054)); PRINTF(("%8x", (unsigned int)3735929054)); PRINTF(("%9x", (unsigned int)3735929054)); PRINTF(("the password is %7x", (unsigned int)3735929054)); PRINTF(("the password is %8x", (unsigned int)3735929054)); PRINTF(("the password is %9x", (unsigned int)3735929054)); PRINTF(("%1x is the definitive answer", (unsigned int)66)); PRINTF(("%2x is the definitive answer", (unsigned int)66)); PRINTF(("%3x is the definitive answer", (unsigned int)66)); PRINTF(("this is the real number: %7x", (unsigned int)-1)); PRINTF(("this is the real number: %8x", (unsigned int)-1)); PRINTF(("this is the real number: %9x", (unsigned int)-1)); PRINTF(("%1x%2x%9x", (unsigned int)-1, 0xf0ca, 123456)); PRINTF(("%1xis doomed%2xpost%9xX args", (unsigned int)-1, 0xf0b1a, 7654321)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_BIG_X && test_cat & CAT_BONUS_1) : 1; describe("\n%X and widths"); PRINTF(("%1X", 0)); PRINTF(("%2X", 1)); PRINTF(("%3X", 10)); PRINTF(("%1X", 16)); PRINTF(("%2X", 160)); PRINTF(("%3X", 255)); PRINTF(("%42X", 256)); PRINTF(("%7X", (unsigned int)3735929054)); PRINTF(("%8X", (unsigned int)3735929054)); PRINTF(("%9X", (unsigned int)3735929054)); PRINTF(("the password is %7X", (unsigned int)3735929054)); PRINTF(("the password is %8X", (unsigned int)3735929054)); PRINTF(("the password is %9X", (unsigned int)3735929054)); PRINTF(("%1X is the definitive answer", (unsigned int)66)); PRINTF(("%2X is the definitive answer", (unsigned int)66)); PRINTF(("%3X is the definitive answer", (unsigned int)66)); PRINTF(("this is the real number: %7X", (unsigned int)-1)); PRINTF(("this is the real number: %8X", (unsigned int)-1)); PRINTF(("this is the real number: %9X", (unsigned int)-1)); PRINTF(("%1X%2X%9X", (unsigned int)-1, 0xf0ca, 123456)); PRINTF(("%1Xis doomed%2Xpost%9Xx args", (unsigned int)-1, 0xf0b1a, 7654321)); describe("\n%s and precisions"); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_S && test_cat & CAT_BONUS_1) : 1; PRINTF(("%.s", "hi there")); PRINTF(("%.0s", "hi there")); PRINTF(("%.1s", "hi there")); PRINTF(("%.2s", "hi there")); PRINTF(("%.3s", "hi there")); PRINTF(("%.4s", "hi there")); PRINTF(("%.7s", "hi there")); PRINTF(("%.8s", "hi there")); PRINTF(("%.9s", "hi there")); PRINTF(("%.12s", "hi there")); PRINTF(("%.s", "-42")); PRINTF(("%.0s", "-42")); PRINTF(("%.1s", "-42")); PRINTF(("%.2s", "-42")); PRINTF(("%.3s", "-42")); PRINTF(("%.4s", "-42")); PRINTF(("%.7s", "-42")); PRINTF(("%.s", "")); PRINTF(("%.0s", "")); PRINTF(("%.1s", "")); PRINTF(("%.5s", "")); PRINTF_EXPECTED(("%.1s", null_str), /* expected: */ ("(")); PRINTF_EXPECTED(("%.2s", null_str), /* expected: */ ("(n")); PRINTF_EXPECTED(("%.5s", null_str), /* expected: */ ("(null")); PRINTF(("%.6s", null_str)); PRINTF(("%.7s", null_str)); PRINTF(("%.2s, motherfucker", "hi there")); PRINTF(("This %.3s a triumph ", "wasabi")); PRINTF(("%.4s making a %.4s here: %.13s", "I'm delighted", "notation", "HUGE SUCCESS!")); PRINTF(("It's %.4s to over%.50s my%s", "hardware", "state", " satisfaction")); PRINTF(("%.11s%.6s%.4s", "Aperture", " Scientists", "ce")); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_D && test_cat & CAT_BONUS_1) : 1; describe("\n%d and precisions"); PRINTF(("%.1d", 2)) PRINTF(("%.2d", 3)) PRINTF(("%.4d", 32)) PRINTF(("%.3d", 420000)) PRINTF(("%.0d", 420000)) PRINTF(("%.3d", -1)) PRINTF(("%.3d", -1234)) PRINTF(("%.4d", -1234)) PRINTF(("%.5d", -1234)) PRINTF(("%.5d", (int)-2147483648)) PRINTF(("%.9d", (int)-2147483648)) PRINTF(("%.10d", (int)-2147483648)) PRINTF(("%.11d", (int)-2147483648)) PRINTF(("%.12d", (int)-2147483648)) PRINTF(("%.13d", (int)-2147483648)) PRINTF(("%.5d", 2147483647)) PRINTF(("%.9d", 2147483647)) PRINTF(("%.10d", 2147483647)) PRINTF(("%.11d", 2147483647)) PRINTF(("%.12d", 2147483647)) PRINTF(("%.0d", 2)) PRINTF(("%.0d", 2147483647)) PRINTF(("%.0d", 0)) PRINTF(("%.0d", 10)) PRINTF(("%.d", 10)) PRINTF(("%.d", 0)) PRINTF(("I'm gonna watch %.3d", 7)) PRINTF(("%.3d is the movie I'm gonna watch", 7)) PRINTF(("Then take these %.7d things and get the hell out of here", 2)) PRINTF(("Bla %.2di bla %.5dsbla bla %.dx bla %.d", 127, 42, 1023, 0)) PRINTF(("%.4d%.2d%.20d%.0d%.0d%.d%.d%.d", 127, 0, 1023, 0, (int)-2147483648, 0, 1, (int)-2147483648)) right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_I && test_cat & CAT_BONUS_1) : 1; describe("\n%i and precisions"); PRINTF(("%.1i", 7)) PRINTF(("%.3i", 7)) PRINTF(("%.2i", 3)) PRINTF(("%.4i", 32)) PRINTF(("%.3i", 420000)) PRINTF(("%.0i", 420000)) PRINTF(("%.3i", -1)) PRINTF(("%.3i", -1234)) PRINTF(("%.4i", -1234)) PRINTF(("%.5i", -1234)) PRINTF(("%.5i", (int)-2147483648)) PRINTF(("%.9i", (int)-2147483648)) PRINTF(("%.10i", (int)-2147483648)) PRINTF(("%.11i", (int)-2147483648)) PRINTF(("%.12i", (int)-2147483648)) PRINTF(("%.13i", (int)-2147483648)) PRINTF(("%.5i", 2147483647)) PRINTF(("%.9i", 2147483647)) PRINTF(("%.10i", 2147483647)) PRINTF(("%.11i", 2147483647)) PRINTF(("%.12i", 2147483647)) PRINTF(("%.0i", 2)) PRINTF(("%.0i", 2147483647)) PRINTF(("%.0i", 0)) PRINTF(("%.0i", 10)) PRINTF(("%.i", 10)) PRINTF(("%.i", 0)) PRINTF(("I'm gonna watch %.3i", 7)) PRINTF(("%.3i is the movie I'm gonna watch", 7)) PRINTF(("Then take these %.7i things and get the hell out of here", 2)) PRINTF(("Bla %.2ii bla %.5isbla bla %.ix bla %.i", 127, 42, 1023, 0)) PRINTF(("%.4i%.2i%.20i%.0i%.0i%.i%.i%.i", 127, 0, 1023, 0, (int)-2147483648, 0, 1, (int)-2147483648)) right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_U && test_cat & CAT_BONUS_1) : 1; describe("\n%u and precisions"); PRINTF(("%.1u", 1)) PRINTF(("%.2u", 1)) PRINTF(("%.2u", 0)) PRINTF(("%.0u", 0)) PRINTF(("%.u", 0)) PRINTF(("%.2u", 30000)) PRINTF(("%.20u", 30000)) PRINTF(("%.0u", (unsigned int)-1)) PRINTF(("%.5u", (unsigned int)-1)) PRINTF(("%.9u", (unsigned int)-1)) PRINTF(("%.10u", (unsigned int)-1)) PRINTF(("%.11u", (unsigned int)-1)) PRINTF(("%.10uis a big number", (unsigned int)-1)) PRINTF(("%.0uis a big number", (unsigned int)-1)) PRINTF(("%.4us a big number", (unsigned int)-1)) PRINTF(("%.9uxs a big number", (unsigned int)-1)) PRINTF(("%.11ups a big number", (unsigned int)-1)) PRINTF(("the number is %.0u", (unsigned int)-1)) PRINTF(("the number is %.u", (unsigned int)-1)) PRINTF(("the number is %.5u", (unsigned int)-1)) PRINTF(("the number is %.9u", (unsigned int)-1)) PRINTF(("the number is %.10u", (unsigned int)-1)) PRINTF(("the number is %.11u", (unsigned int)-1)) PRINTF(("the number is %.11u", (unsigned int)-1)) PRINTF(("%.0uis a big number", 0)) PRINTF(("%.4us a big number", 0)) PRINTF(("the number is %.0u", 0)) PRINTF(("the number is %.u", 0)) PRINTF(("the number is %.5u", 0)) PRINTF(("%u%.5u%.0u%.u%.9u", 5, 55, 2, 0, 42)) PRINTF(("%us%.5ui%.0uc%.up%.9ux", 5, 55, 2, 0, 42)) right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_X && test_cat & CAT_BONUS_1) : 1; describe("\n%x and precisions"); PRINTF(("%.1x", 0xa)) PRINTF(("%.4x", 11)) PRINTF(("%.0x", 0)) PRINTF(("%.1x", -1)) PRINTF(("%.10x", -1)) PRINTF(("%.14x", -1)) PRINTF(("%.8x", 0)) PRINTF(("%.2x", 30000)) PRINTF(("%.20x", 30000)) PRINTF(("%.0x", (unsigned int)-1)) PRINTF(("%.5x", (unsigned int)-1)) PRINTF(("%.9x", (unsigned int)-1)) PRINTF(("%.10x", (unsigned int)-1)) PRINTF(("%.11x", (unsigned int)-1)) PRINTF(("%.10xis a big number", (unsigned int)-1)) PRINTF(("%.0xis a big number", (unsigned int)-1)) PRINTF(("%.4xs a big number", (unsigned int)-1)) PRINTF(("%.9xxs a big number", (unsigned int)-1)) PRINTF(("%.11xps a big number", (unsigned int)-1)) PRINTF(("the number is %.0x", (unsigned int)-1)) PRINTF(("the number is %.x", (unsigned int)-1)) PRINTF(("the number is %.5x", (unsigned int)-1)) PRINTF(("the number is %.9x", (unsigned int)-1)) PRINTF(("the number is %.10x", (unsigned int)-1)) PRINTF(("the number is %.11x", (unsigned int)-1)) PRINTF(("the number is %.11x", (unsigned int)-1)) PRINTF(("%.0xis a big number", 0)) PRINTF(("%.4xs a big number", 0)) PRINTF(("the number is %.0x", 0)) PRINTF(("the number is %.x", 0)) PRINTF(("the number is %.5x", 0)) PRINTF(("%x%.5x%.0x%.x%.9x", 5, 55, 2, 0, 42)) PRINTF(("%xs%.5xi%.0xc%.xp%.9xu", 5, 55, 2, 0, 42)) right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_BIG_X && test_cat & CAT_BONUS_1) : 1; describe("\n%X and precisions"); PRINTF(("%.1X", 0xa)) PRINTF(("%.4X", 11)) PRINTF(("%.0X", 0)) PRINTF(("%.1X", -1)) PRINTF(("%.10X", -1)) PRINTF(("%.14X", -1)) PRINTF(("%.8X", 0)) PRINTF(("%.2X", 30000)) PRINTF(("%.20X", 30000)) PRINTF(("%.0X", (unsigned int)-1)) PRINTF(("%.5X", (unsigned int)-1)) PRINTF(("%.9X", (unsigned int)-1)) PRINTF(("%.10X", (unsigned int)-1)) PRINTF(("%.11X", (unsigned int)-1)) PRINTF(("%.10Xis a big number", (unsigned int)-1)) PRINTF(("%.0Xis a big number", (unsigned int)-1)) PRINTF(("%.4Xs a big number", (unsigned int)-1)) PRINTF(("%.9XXs a big number", (unsigned int)-1)) PRINTF(("%.11Xps a big number", (unsigned int)-1)) PRINTF(("the number is %.0X", (unsigned int)-1)) PRINTF(("the number is %.X", (unsigned int)-1)) PRINTF(("the number is %.5X", (unsigned int)-1)) PRINTF(("the number is %.9X", (unsigned int)-1)) PRINTF(("the number is %.10X", (unsigned int)-1)) PRINTF(("the number is %.11X", (unsigned int)-1)) PRINTF(("the number is %.11X", (unsigned int)-1)) PRINTF(("%.0Xis a big number", 0)) PRINTF(("%.4Xs a big number", 0)) PRINTF(("the number is %.0X", 0)) PRINTF(("the number is %.X", 0)) PRINTF(("the number is %.5X", 0)) PRINTF(("%X%.5X%.0X%.X%.9X", 5, 55, 2, 0, 42)) PRINTF(("%Xs%.5Xi%.0Xc%.Xp%.9Xu", 5, 55, 2, 0, 42)) right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_C && test_cat & CAT_BONUS_1) : 1; describe("\n%c, widths and -"); // this is literally a negative width '-' PRINTF(("%-c", 'p')); PRINTF(("%-c%-c%c*", 0, '1', 1)); PRINTF(("%-1c", 'b')); PRINTF(("%-5c", 'w')); PRINTF((" kk daora%-5cblz", 'w')); PRINTF(("%-20carigatou", 'w')); PRINTF(("%-c%-c%-4c%-11c", 'a', 'b', 'c', 'd')); PRINTF(("%-ci%-cp%4cs%-11cx", 'a', 'b', 'c', 'd')); PRINTF(("%----ci%---cp%4cs%--11cx", 'a', 'b', 'c', 'd')); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_S && test_cat & CAT_BONUS_1) : 1; describe("\n%s, widths, precisions and -"); PRINTF(("%-sScience!", "Aperture")); PRINTF(("%-9sScience!", "Aperture")); PRINTF(("We %-s what we %8s, %-2s we %-20s", "do", "must", "because", "can")); PRINTF(("%--4s %s %------------------9s of %s of %-5s", "for", "the", "goooood", "aaall", "us")); PRINTF(("%--4.1s %s %------------------9.3s of %s of %-5.7s", "for", "the", "goooood", "aaall", "us")); PRINTF(("%--.sp--.su kkkk", "pegadinha po")); PRINTF(("%-9sScience!", "-42")); PRINTF(("%-s %-.7s!", "Aperture", "Science")); PRINTF(("%-sScience!", "")); PRINTF(("%-1sScience!", "")); PRINTF(("%-9.2sScience!", "")); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_P && test_cat & CAT_BONUS_1) : 1; describe("\n%p, widths and -"); PRINTF(("that's the way it %-20pis", "")); PRINTF(("as soon as %-10possible", (void *) -1)); PRINTF(("as soon as %-16peasible", (void *) (((long int)3 << 42) + 15))); PRINTF(("as soon as %-16peasible", (void *) (((long int)3 << 42) + 15))); PRINTF(("thats %-psrobably not a good idea", (void *) 13)); PRINTF(("%------21pwhoa wtf is that", (void *) 13)); PRINTF(("%------21p yeah i'm %p running out %--p of ideas", (void *) 13, (void *) 65, (void *) -1)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_D && test_cat & CAT_BONUS_1) : 1; describe("\n%d, widths, precisions and -"); PRINTF(("%-d", 0)); PRINTF(("%-d", 1)); PRINTF(("%-d", 10)); PRINTF(("%-d", -10)); PRINTF(("%-d", 5000)); PRINTF(("%-d", -5000)); PRINTF(("%-d", (int)-2147483648)); PRINTF(("%-d", 2147483647)); PRINTF(("%-1d", 0)); PRINTF(("%-1d", 1)); PRINTF(("%-1d", 10)); PRINTF(("%-1d", -10)); PRINTF(("%-1d", 5000)); PRINTF(("%-1d", -5000)); PRINTF(("%-1d", (int)-2147483648)); PRINTF(("%-1d", 2147483647)); PRINTF(("%-10d", 0)); PRINTF(("%-10d", 1)); PRINTF(("%-10d", 10)); PRINTF(("%-10d", -10)); PRINTF(("%-10d", 5000)); PRINTF(("%-10d", -5000)); PRINTF(("%-10d", (int)-2147483648)); PRINTF(("%-10d", 2147483647)); PRINTF(("%-.d", 0)); PRINTF(("%-.1d", 1)); PRINTF(("%-.2d", 10)); PRINTF(("%-.3d", -10)); PRINTF(("%-.4d", 5000)); PRINTF(("%-.5d", -5000)); PRINTF(("%-.6d", (int)-2147483648)); PRINTF(("%-.7d", 2147483647)); PRINTF(("%-1.8d", 0)); PRINTF(("%-1.9d", 1)); PRINTF(("%-1.10d", 10)); PRINTF(("%-1.0d", -10)); PRINTF(("%-1.6d", 5000)); PRINTF(("%-1.4d", -5000)); PRINTF(("%-1.10d", (int)-2147483648)); PRINTF(("%-1.12d", 2147483647)); PRINTF(("%-10.d", 0)); PRINTF(("%-10.10d", 1)); PRINTF(("%-10.5d", 10)); PRINTF(("%-10.2d", -10)); PRINTF(("%-10.5d", 5000)); PRINTF(("%-10.5d", -5000)); PRINTF(("%-10.15d", (int)-2147483648)); PRINTF(("%-10.5d", 2147483647)); PRINTF(("%-15.d", 0)); PRINTF(("%-15.10d", 1)); PRINTF(("%-15.5d", 10)); PRINTF(("%-15.2d", -10)); PRINTF(("%-15.5d", 5000)); PRINTF(("%-15.5d", -5000)); PRINTF(("%-15.15d", (int)-2147483648)); PRINTF(("%-15.5d", 2147483647)); PRINTF(("%-4.5d%d%4d%-10d-d5%-.3d", 3, 4, 5, 6, 7)); PRINTF(("%-4.5d%d%4d%-10d-d5%-.3d", 300000, 400000, 500000, 600000, 700000)); PRINTF(("%-4.5d%d%4d%-10d-d5%-.3d", -300000, -400000, -500000, -600000, -700000)); PRINTF(("%-4.5d%d%4d%-10d-d5%-.3d", 2147483647, 2141483647, 2141483647, 2141483647, 2141483647)); PRINTF(("%-4.5d%d%4d%-10d-d5%-.3d", (int)-2147483648, (int)-2141483648, (int)-2141483648, (int)-2141483648, (int)-2141483648)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_I && test_cat & CAT_BONUS_1) : 1; describe("\n%i, widths, precisions and -"); PRINTF(("%-i", 0)); PRINTF(("%-i", 1)); PRINTF(("%-i", 10)); PRINTF(("%-i", -10)); PRINTF(("%-i", 5000)); PRINTF(("%-i", -5000)); PRINTF(("%-i", (int)-2147483648)); PRINTF(("%-i", 2147483647)); PRINTF(("%-1i", 0)); PRINTF(("%-1i", 1)); PRINTF(("%-1i", 10)); PRINTF(("%-1i", -10)); PRINTF(("%-1i", 5000)); PRINTF(("%-1i", -5000)); PRINTF(("%-1i", (int)-2147483648)); PRINTF(("%-1i", 2147483647)); PRINTF(("%-10i", 0)); PRINTF(("%-10i", 1)); PRINTF(("%-10i", 10)); PRINTF(("%-10i", -10)); PRINTF(("%-10i", 5000)); PRINTF(("%-10i", -5000)); PRINTF(("%-10i", (int)-2147483648)); PRINTF(("%-10i", 2147483647)); PRINTF(("%-.i", 0)); PRINTF(("%-.1i", 1)); PRINTF(("%-.2i", 10)); PRINTF(("%-.3i", -10)); PRINTF(("%-.4i", 5000)); PRINTF(("%-.5i", -5000)); PRINTF(("%-.6i", (int)-2147483648)); PRINTF(("%-.7i", 2147483647)); PRINTF(("%-1.8i", 0)); PRINTF(("%-1.9i", 1)); PRINTF(("%-1.10i", 10)); PRINTF(("%-1.0i", -10)); PRINTF(("%-1.6i", 5000)); PRINTF(("%-1.4i", -5000)); PRINTF(("%-1.10i", (int)-2147483648)); PRINTF(("%-1.12i", 2147483647)); PRINTF(("%-10.i", 0)); PRINTF(("%-10.10i", 1)); PRINTF(("%-10.5i", 10)); PRINTF(("%-10.2i", -10)); PRINTF(("%-10.5i", 5000)); PRINTF(("%-10.5i", -5000)); PRINTF(("%-10.15i", (int)-2147483648)); PRINTF(("%-10.5i", 2147483647)); PRINTF(("%-15.i", 0)); PRINTF(("%-15.10i", 1)); PRINTF(("%-15.5i", 10)); PRINTF(("%-15.2i", -10)); PRINTF(("%-15.5i", 5000)); PRINTF(("%-15.5i", -5000)); PRINTF(("%-15.15i", (int)-2147483648)); PRINTF(("%-15.5i", 2147483647)); PRINTF(("%-4.5i%i%4i%-10i-i5%-.3i", 3, 4, 5, 6, 7)); PRINTF(("%-4.5i%i%4i%-10i-i5%-.3i", 300000, 400000, 500000, 600000, 700000)); PRINTF(("%-4.5i%i%4i%-10i-i5%-.3i", -300000, -400000, -500000, -600000, -700000)); PRINTF(("%-4.5i%i%4i%-10i-i5%-.3i", 2147483647, 2141483647, 2141483647, 2141483647, 2141483647)); PRINTF(("%-4.5i%i%4i%-10i-i5%-.3i", (int)-2147483648, (int)-2141483648, (int)-2141483648, (int)-2141483648, (int)-2141483648)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_U && test_cat & CAT_BONUS_1) : 1; describe("\n%u, widths, precisions and -"); PRINTF(("%-u", 0)); PRINTF(("%-u", 1)); PRINTF(("%-u", 10)); PRINTF(("%-u", -10)); PRINTF(("%-u", 5000)); PRINTF(("%-u", -5000)); PRINTF(("%-u", (unsigned int)-1)); PRINTF(("%-u", 2147483647)); PRINTF(("%-1u", 0)); PRINTF(("%-1u", 1)); PRINTF(("%-1u", 10)); PRINTF(("%-1u", -10)); PRINTF(("%-1u", 5000)); PRINTF(("%-1u", -5000)); PRINTF(("%-1u", (unsigned int)-1)); PRINTF(("%-1u", 2147483647)); PRINTF(("%-10u", 0)); PRINTF(("%-10u", 1)); PRINTF(("%-10u", 10)); PRINTF(("%-10u", -10)); PRINTF(("%-10u", 5000)); PRINTF(("%-10u", -5000)); PRINTF(("%-10u", -1)); PRINTF(("%-10u", 2147483647)); PRINTF(("%-.u", 0)); PRINTF(("%-.1u", 1)); PRINTF(("%-.2u", 10)); PRINTF(("%-.3u", -10)); PRINTF(("%-.4u", 5000)); PRINTF(("%-.5u", -5000)); PRINTF(("%-.6u", -1)); PRINTF(("%-.7u", 2147483647)); PRINTF(("%-1.8u", 0)); PRINTF(("%-1.9u", 1)); PRINTF(("%-1.10u", 10)); PRINTF(("%-1.0u", -10)); PRINTF(("%-1.6u", 5000)); PRINTF(("%-1.4u", -5000)); PRINTF(("%-1.10u", -1)); PRINTF(("%-1.12u", 2147483647)); PRINTF(("%-10.u", 0)); PRINTF(("%-10.10u", 1)); PRINTF(("%-10.5u", 10)); PRINTF(("%-10.2u", -10)); PRINTF(("%-10.5u", 5000)); PRINTF(("%-10.5u", -5000)); PRINTF(("%-10.15u", -1)); PRINTF(("%-10.5u", 2147483647)); PRINTF(("%-15.u", 0)); PRINTF(("%-15.10u", 1)); PRINTF(("%-15.5u", 10)); PRINTF(("%-15.2u", -10)); PRINTF(("%-15.5u", 5000)); PRINTF(("%-15.5u", -5000)); PRINTF(("%-15.15u", -1)); PRINTF(("%-15.5u", 2147483647)); PRINTF(("%-4.5u%u%4u%-10u-u5%-.3u", 3, 4, 5, 6, 7)); PRINTF(("%-4.5u%u%4u%-10u-u5%-.3u", 300000, 400000, 500000, 600000, 700000)); PRINTF(("%-4.5u%u%4u%-10u-u5%-.3u", -300000, -400000, -500000, -600000, -700000)); PRINTF(("%-4.5u%u%4u%-10u-u5%-.3u", 2147483647, 2141483647, 2141483647, 2141483647, 2141483647)); PRINTF(("%-4.5u%u%4u%-10u-u5%-.3u", -1, -1, -1, -1, -1)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_X && test_cat & CAT_BONUS_1) : 1; describe("\n%x, widths, precisions and -"); PRINTF(("%-x", 0)); PRINTF(("%-x", 1)); PRINTF(("%-x", 10)); PRINTF(("%-x", -10)); PRINTF(("%-x", 5000)); PRINTF(("%-x", -5000)); PRINTF(("%-x", -1)); PRINTF(("%-x", 2147483647)); PRINTF(("%-1x", 0)); PRINTF(("%-1x", 1)); PRINTF(("%-1x", 10)); PRINTF(("%-1x", -10)); PRINTF(("%-1x", 5000)); PRINTF(("%-1x", -5000)); PRINTF(("%-1x", -1)); PRINTF(("%-1x", 2147483647)); PRINTF(("%-10x", 0)); PRINTF(("%-10x", 1)); PRINTF(("%-10x", 10)); PRINTF(("%-10x", -10)); PRINTF(("%-10x", 5000)); PRINTF(("%-10x", -5000)); PRINTF(("%-10x", -1)); PRINTF(("%-10x", 2147483647)); PRINTF(("%-.x", 0)); PRINTF(("%-.1x", 1)); PRINTF(("%-.2x", 10)); PRINTF(("%-.3x", -10)); PRINTF(("%-.4x", 5000)); PRINTF(("%-.5x", -5000)); PRINTF(("%-.6x", -1)); PRINTF(("%-.7x", 2147483647)); PRINTF(("%-1.8x", 0)); PRINTF(("%-1.9x", 1)); PRINTF(("%-1.10x", 10)); PRINTF(("%-1.0x", -10)); PRINTF(("%-1.6x", 5000)); PRINTF(("%-1.4x", -5000)); PRINTF(("%-1.10x", -1)); PRINTF(("%-1.12x", 2147483647)); PRINTF(("%-10.x", 0)); PRINTF(("%-10.10x", 1)); PRINTF(("%-10.5x", 10)); PRINTF(("%-10.2x", -10)); PRINTF(("%-10.5x", 5000)); PRINTF(("%-10.5x", -5000)); PRINTF(("%-10.15x", -1)); PRINTF(("%-10.5x", 2147483647)); PRINTF(("%-15.x", 0)); PRINTF(("%-15.10x", 1)); PRINTF(("%-15.5x", 10)); PRINTF(("%-15.2x", -10)); PRINTF(("%-15.5x", 5000)); PRINTF(("%-15.5x", -5000)); PRINTF(("%-15.15x", -1)); PRINTF(("%-15.5x", 2147483647)); PRINTF(("%-4.5x%x%4x%-10x-x5%-.3x", 3, 4, 5, 6, 7)); PRINTF(("%-4.5x%x%4x%-10x-x5%-.3x", 300000, 400000, 500000, 600000, 700000)); PRINTF(("%-4.5x%x%4x%-10x-x5%-.3x", -300000, -400000, -500000, -600000, -700000)); PRINTF(("%-4.5x%x%4x%-10x-x5%-.3x", 2147483647, 2141483647, 2141483647, 2141483647, 2141483647)); PRINTF(("%-4.5x%x%4x%-10x-x5%-.3x", -1, -1, -1, -1, -1)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_BIG_X && test_cat & CAT_BONUS_1) : 1; describe("\n%X, widths, precisions and -"); PRINTF(("%-X", 0)); PRINTF(("%-X", 1)); PRINTF(("%-X", 10)); PRINTF(("%-X", -10)); PRINTF(("%-X", 5000)); PRINTF(("%-X", -5000)); PRINTF(("%-X", -1)); PRINTF(("%-X", 2147483647)); PRINTF(("%-1X", 0)); PRINTF(("%-1X", 1)); PRINTF(("%-1X", 10)); PRINTF(("%-1X", -10)); PRINTF(("%-1X", 5000)); PRINTF(("%-1X", -5000)); PRINTF(("%-1X", -1)); PRINTF(("%-1X", 2147483647)); PRINTF(("%-10X", 0)); PRINTF(("%-10X", 1)); PRINTF(("%-10X", 10)); PRINTF(("%-10X", -10)); PRINTF(("%-10X", 5000)); PRINTF(("%-10X", -5000)); PRINTF(("%-10X", -1)); PRINTF(("%-10X", 2147483647)); PRINTF(("%-.X", 0)); PRINTF(("%-.1X", 1)); PRINTF(("%-.2X", 10)); PRINTF(("%-.3X", -10)); PRINTF(("%-.4X", 5000)); PRINTF(("%-.5X", -5000)); PRINTF(("%-.6X", -1)); PRINTF(("%-.7X", 2147483647)); PRINTF(("%-1.8X", 0)); PRINTF(("%-1.9X", 1)); PRINTF(("%-1.10X", 10)); PRINTF(("%-1.0X", -10)); PRINTF(("%-1.6X", 5000)); PRINTF(("%-1.4X", -5000)); PRINTF(("%-1.10X", -1)); PRINTF(("%-1.12X", 2147483647)); PRINTF(("%-10.X", 0)); PRINTF(("%-10.10X", 1)); PRINTF(("%-10.5X", 10)); PRINTF(("%-10.2X", -10)); PRINTF(("%-10.5X", 5000)); PRINTF(("%-10.5X", -5000)); PRINTF(("%-10.15X", -1)); PRINTF(("%-10.5X", 2147483647)); PRINTF(("%-15.X", 0)); PRINTF(("%-15.10X", 1)); PRINTF(("%-15.5X", 10)); PRINTF(("%-15.2X", -10)); PRINTF(("%-15.5X", 5000)); PRINTF(("%-15.5X", -5000)); PRINTF(("%-15.15X", -1)); PRINTF(("%-15.5X", 2147483647)); PRINTF(("%-4.5X%X%4X%-10X-X5%-.3X", 3, 4, 5, 6, 7)); PRINTF(("%-4.5X%X%4X%-10X-X5%-.3X", 300000, 400000, 500000, 600000, 700000)); PRINTF(("%-4.5X%X%4X%-10X-X5%-.3X", -300000, -400000, -500000, -600000, -700000)); PRINTF(("%-4.5X%X%4X%-10X-X5%-.3X", 2147483647, 2141483647, 2141483647, 2141483647, 2141483647)); PRINTF(("%-4.5X%X%4X%-10X-X5%-.3X", -1, -1, -1, -1, -1)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_D && test_cat & CAT_BONUS_1) : 1; describe("\n%d, widths, precisions and 0"); PRINTF(("%01d", 0)); PRINTF(("%01d", -4)); PRINTF(("%010d", 42)); PRINTF(("%042d", 42000)); PRINTF(("%020d", -42000)); PRINTF(("wait for it... %050d", 42)); PRINTF(("%020d is how many tests are going to be made", 8000)); PRINTF(("%05d", 2147483647)); PRINTF(("%030d", 2147483647)); PRINTF(("%010d", 2147483647)); PRINTF(("%05d", (int)-2147483648)); PRINTF(("%030d", (int)-2147483648)); PRINTF(("%010d", (int)-2147483648)); PRINTF(("%011d", (int)-2147483648)); PRINTF(("%012d", (int)-2147483648)); PRINTF(("%012d, %20d, %2d, %42d", (int)-2147483648, 3, 30, -1)); PRINTF(("%012d, %d, %2d, %42d", (int)-2147483648, 3, 30, -1)); PRINTF(("%014d%020d%02d%0d", (int)-2147483648, 3, 30, -1)); PRINTF(("%014dc%020ds%02dx%0du", (int)-2147483648, 3, 30, -1)); PRINTF(("%01.d", 0)); PRINTF(("%01.0d", 0)); PRINTF(("%02.0d", 0)); PRINTF(("%03.0d", 0)); PRINTF(("%01.1d", 0)); PRINTF(("%01.2d", 0)); PRINTF(("%01.3d", 0)); PRINTF(("%01.0d", -4)); PRINTF(("%01.1d", -4)); PRINTF(("%01.2d", -4)); PRINTF(("%01.3d", -4)); PRINTF(("%01.0d", 4)); PRINTF(("%01.1d", 4)); PRINTF(("%01.2d", 4)); PRINTF(("%01.3d", 4)); PRINTF(("%010.20d", 42)); PRINTF(("%042.2d", 42000)); PRINTF(("%042.20d", 42000)); PRINTF(("%042.42d", 42000)); PRINTF(("%042.52d", 42000)); PRINTF(("%020.10d", -42000)); PRINTF(("%020.20d", -42000)); PRINTF(("%020.30d", -42000)); PRINTF(("wait for it... %050.50d", 42)); PRINTF(("%020.19d is how many tests are going to be made", 8000)); PRINTF(("%020.20d is how many tests are going to be made", 8000)); PRINTF(("%020.21d is how many tests are going to be made", 8000)); PRINTF(("%05d", 2147483647)); PRINTF(("%030d", 2147483647)); PRINTF(("%09d", 2147483647)); PRINTF(("%010d", 2147483647)); PRINTF(("%011d", 2147483647)); PRINTF(("%05d", (int)-2147483648)); PRINTF(("%030d", (int)-2147483648)); PRINTF(("%010d", (int)-2147483648)); PRINTF(("%011d", (int)-2147483648)); PRINTF(("%012d", (int)-2147483648)); PRINTF(("%012d, %20d, %2d, %000042d", (int)-2147483648, 3, 30, -1)); PRINTF(("%012d, %d, %002d, %42d", (int)-2147483648, 3, 30, -1)); PRINTF(("%0014.2d%020d%0002.d%000.5d", (int)-2147483648, 3, 30, -1)); PRINTF(("%014dc%020ds%02dx%0du", (int)-2147483648, 3, 30, -1)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_I && test_cat & CAT_BONUS_1) : 1; describe("\n%i, widths, precisions and 0"); PRINTF(("%01i", 0)); PRINTF(("%01i", -4)); PRINTF(("%010i", 42)); PRINTF(("%042i", 42000)); PRINTF(("%020i", -42000)); PRINTF(("wait for it... %050i", 42)); PRINTF(("%020i is how many tests are going to be maie", 8000)); PRINTF(("%05i", 2147483647)); PRINTF(("%030i", 2147483647)); PRINTF(("%010i", 2147483647)); PRINTF(("%05i", (int)-2147483648)); PRINTF(("%030i", (int)-2147483648)); PRINTF(("%010i", (int)-2147483648)); PRINTF(("%011i", (int)-2147483648)); PRINTF(("%012i", (int)-2147483648)); PRINTF(("%012i, %20i, %2i, %42i", (int)-2147483648, 3, 30, -1)); PRINTF(("%012i, %i, %2i, %42i", (int)-2147483648, 3, 30, -1)); PRINTF(("%014i%020i%02i%0i", (int)-2147483648, 3, 30, -1)); PRINTF(("%014ic%020is%02ix%0iu", (int)-2147483648, 3, 30, -1)); PRINTF(("%01.i", 0)); PRINTF(("%01.0i", 0)); PRINTF(("%02.0i", 0)); PRINTF(("%03.0i", 0)); PRINTF(("%01.1i", 0)); PRINTF(("%01.2i", 0)); PRINTF(("%01.3i", 0)); PRINTF(("%01.0i", -4)); PRINTF(("%01.1i", -4)); PRINTF(("%01.2i", -4)); PRINTF(("%01.3i", -4)); PRINTF(("%01.0i", 4)); PRINTF(("%01.1i", 4)); PRINTF(("%01.2i", 4)); PRINTF(("%01.3i", 4)); PRINTF(("%010.20i", 42)); PRINTF(("%042.2i", 42000)); PRINTF(("%042.20i", 42000)); PRINTF(("%042.42i", 42000)); PRINTF(("%042.52i", 42000)); PRINTF(("%020.10i", -42000)); PRINTF(("%020.20i", -42000)); PRINTF(("%020.30i", -42000)); PRINTF(("wait for it... %050.50i", 42)); PRINTF(("%020.19i is how many tests are going to be made", 8000)); PRINTF(("%020.20i is how many tests are going to be made", 8000)); PRINTF(("%020.21i is how many tests are going to be made", 8000)); PRINTF(("%05i", 2147483647)); PRINTF(("%030i", 2147483647)); PRINTF(("%09i", 2147483647)); PRINTF(("%010i", 2147483647)); PRINTF(("%011i", 2147483647)); PRINTF(("%05i", (int)-2147483648)); PRINTF(("%030i", (int)-2147483648)); PRINTF(("%010i", (int)-2147483648)); PRINTF(("%011i", (int)-2147483648)); PRINTF(("%012i", (int)-2147483648)); PRINTF(("%012i, %20i, %2i, %000042i", (int)-2147483648, 3, 30, -1)); PRINTF(("%012i, %i, %002i, %42i", (int)-2147483648, 3, 30, -1)); PRINTF(("%0014.2i%020i%0002.i%000.5i", (int)-2147483648, 3, 30, -1)); PRINTF(("%014ic%020is%02ix%0iu", (int)-2147483648, 3, 30, -1)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_U && test_cat & CAT_BONUS_1) : 1; describe("\n%u, widths, precisions and 0"); PRINTF(("%01u", 0)); PRINTF(("%01u", -4)); PRINTF(("%010u", 42)); PRINTF(("%042u", 42000)); PRINTF(("%020u", -42000)); PRINTF(("wait for it... %050u", 42)); PRINTF(("%020u is how many tests are going to be maie", 8000)); PRINTF(("%05u", 2147483647)); PRINTF(("%030u", 2147483647)); PRINTF(("%010u", 2147483647)); PRINTF(("%05u", -1)); PRINTF(("%030u", -1)); PRINTF(("%010u", -1)); PRINTF(("%011u", -1)); PRINTF(("%012u", -1)); PRINTF(("%012u, %20u, %2u, %42u", -1, 3, 30, -1)); PRINTF(("%012u, %u, %2u, %42u", -1, 3, 30, -1)); PRINTF(("%014u%020u%02u%0u", -1, 3, 30, -1)); PRINTF(("%014uc%020us%02ux%0ui", -1, 3, 30, -1)); PRINTF(("%01.u", 0)); PRINTF(("%01.0u", 0)); PRINTF(("%02.0u", 0)); PRINTF(("%03.0u", 0)); PRINTF(("%01.1u", 0)); PRINTF(("%01.2u", 0)); PRINTF(("%01.3u", 0)); PRINTF(("%01.0u", 4)); PRINTF(("%01.1u", 4)); PRINTF(("%01.2u", 4)); PRINTF(("%01.3u", 4)); PRINTF(("%010.20u", 42)); PRINTF(("%042.2u", 42000)); PRINTF(("%042.20u", 42000)); PRINTF(("%042.42u", 42000)); PRINTF(("%042.52u", 42000)); PRINTF(("wait for it... %050.50u", 42)); PRINTF(("%020.19u is how many tests are going to be made", 8000)); PRINTF(("%020.20u is how many tests are going to be made", 8000)); PRINTF(("%020.21u is how many tests are going to be made", 8000)); PRINTF(("%05u", 2147483647)); PRINTF(("%030u", 2147483647)); PRINTF(("%09u", 2147483647)); PRINTF(("%010u", 2147483647)); PRINTF(("%011u", 2147483647)); PRINTF(("%05u", -1)); PRINTF(("%030u", -1)); PRINTF(("%010u", -1)); PRINTF(("%011u", -1)); PRINTF(("%012u", -1)); PRINTF(("%012u, %20u, %2u, %000042u", -1, 3, 30, -1)); PRINTF(("%012u, %u, %002u, %42u", -1, 3, 30, -1)); PRINTF(("%0014.2u%020u%0002.u%000.5u", -1, 3, 30, -1)); PRINTF(("%014uc%020us%02ux%0ui", -1, 3, 30, -1)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_X && test_cat & CAT_BONUS_1) : 1; describe("\n%x, widths, precisions and 0"); PRINTF(("%01x", 0)); PRINTF(("%01x", -4)); PRINTF(("%010x", 42)); PRINTF(("%042x", 42000)); PRINTF(("%020x", -42000)); PRINTF(("wait for it... %050x", 42)); PRINTF(("%020x is how many tests are going to be made", 8000)); PRINTF(("%05x", 2147483647)); PRINTF(("%030x", 2147483647)); PRINTF(("%010x", 2147483647)); PRINTF(("%05x", -1)); PRINTF(("%030x", -1)); PRINTF(("%010x", -1)); PRINTF(("%011x", -1)); PRINTF(("%012x", -1)); PRINTF(("%012x, %20x, %2x, %42x", -1, 3, 30, -1)); PRINTF(("%012x, %x, %2x, %42x", -1, 3, 30, -1)); PRINTF(("%014x%020x%02x%0x", -1, 3, 30, -1)); PRINTF(("%014xc%020xs%02xX%0xi", -1, 3, 30, -1)); PRINTF(("%01.x", 0)); PRINTF(("%01.0x", 0)); PRINTF(("%02.0x", 0)); PRINTF(("%03.0x", 0)); PRINTF(("%01.1x", 0)); PRINTF(("%01.2x", 0)); PRINTF(("%01.3x", 0)); PRINTF(("%01.0x", 4)); PRINTF(("%01.1x", 4)); PRINTF(("%01.2x", 4)); PRINTF(("%01.3x", 4)); PRINTF(("%010.20x", 42)); PRINTF(("%042.2x", 42000)); PRINTF(("%042.20x", 42000)); PRINTF(("%042.42x", 42000)); PRINTF(("%042.52x", 42000)); PRINTF(("wait for it... %050.50x", 42)); PRINTF(("%020.19x is how many tests are going to be made", 8000)); PRINTF(("%020.20x is how many tests are going to be made", 8000)); PRINTF(("%020.21x is how many tests are going to be made", 8000)); PRINTF(("%05x", 2147483647)); PRINTF(("%030x", 2147483647)); PRINTF(("%09x", 2147483647)); PRINTF(("%010x", 2147483647)); PRINTF(("%011x", 2147483647)); PRINTF(("%05x", -1)); PRINTF(("%030x", -1)); PRINTF(("%010x", -1)); PRINTF(("%011x", -1)); PRINTF(("%012x", -1)); PRINTF(("%012x, %20x, %2x, %000042x", -1, 3, 30, -1)); PRINTF(("%012x, %x, %002x, %42x", -1, 3, 30, -1)); PRINTF(("%0014.2x%020x%0002.x%000.5x", -1, 3, 30, -1)); PRINTF(("%014xc%020xs%02xx%0xi", -1, 3, 30, -1)); right_cat = (g_all_bonus & CAT_BONUS_1) ? 1 : test_cat ? (test_cat & CAT_BIG_X && test_cat & CAT_BONUS_1) : 1; describe("\n%X, widths, precisions and 0"); PRINTF(("%01X", 0)); PRINTF(("%01X", -4)); PRINTF(("%010X", 42)); PRINTF(("%042X", 42000)); PRINTF(("%020X", -42000)); PRINTF(("wait for it... %050X", 42)); PRINTF(("%020X is how many tests are going to be made", 8000)); PRINTF(("%05X", 2147483647)); PRINTF(("%030X", 2147483647)); PRINTF(("%010X", 2147483647)); PRINTF(("%05X", -1)); PRINTF(("%030X", -1)); PRINTF(("%010X", -1)); PRINTF(("%011X", -1)); PRINTF(("%012X", -1)); PRINTF(("%012X, %20X, %2X, %42X", -1, 3, 30, -1)); PRINTF(("%012X, %X, %2X, %42X", -1, 3, 30, -1)); PRINTF(("%014X%020X%02X%0X", -1, 3, 30, -1)); PRINTF(("%014Xc%020Xs%02XX%0Xi", -1, 3, 30, -1)); PRINTF(("%01.X", 0)); PRINTF(("%01.0X", 0)); PRINTF(("%02.0X", 0)); PRINTF(("%03.0X", 0)); PRINTF(("%01.1X", 0)); PRINTF(("%01.2X", 0)); PRINTF(("%01.3X", 0)); PRINTF(("%01.0X", 4)); PRINTF(("%01.1X", 4)); PRINTF(("%01.3X", 4)); PRINTF(("%010.20X", 42)); PRINTF(("%042.2X", 42000)); PRINTF(("%042.20X", 42000)); PRINTF(("%042.42X", 42000)); PRINTF(("%042.52X", 42000)); PRINTF(("wait for it... %050.50X", 42)); PRINTF(("%020.19X is how many tests are going to be made", 8000)); PRINTF(("%020.20X is how many tests are going to be made", 8000)); PRINTF(("%020.21X is how many tests are going to be made", 8000)); PRINTF(("%05X", 2147483647)); PRINTF(("%030X", 2147483647)); PRINTF(("%09X", 2147483647)); PRINTF(("%010X", 2147483647)); PRINTF(("%011X", 2147483647)); PRINTF(("%05X", -1)); PRINTF(("%030.20X", -1)); PRINTF(("%010.11X", -1)); PRINTF(("%011.11X", -1)); PRINTF(("%012.11X", -1)); PRINTF(("%012X, %20X, %2X, %000042.20X", -1, 3, 30, -1)); PRINTF(("%012X, %X, %002X, %42.5X", -1, 3, 30, -1)); PRINTF(("%0014.2X%020X%0002.X%000.5X", -1, 3, 30, -1)); PRINTF(("%014Xc%020Xs%02.5XX%0.Xi", -1, 3, 30, -1)); right_cat = (g_all_bonus & CAT_BONUS_2) ? 1 : test_cat ? (test_cat & CAT_X && test_cat & CAT_BONUS_2) : 1; describe("\n%x, widths, precisions and #"); PRINTF(("%#1x", 0)); PRINTF(("%#1x", -4)); PRINTF(("%#10x", 42)); PRINTF(("%#42x", 42000)); PRINTF(("%#20x", -42000)); PRINTF(("wait for it... %#50x", 42)); PRINTF(("%#20x is how many tests are going to be made", 8000)); PRINTF(("%#5x", 2147483647)); PRINTF(("%#30x", 2147483647)); PRINTF(("%#10x", 2147483647)); PRINTF(("%#5x", -1)); PRINTF(("%#30x", -1)); PRINTF(("%#10x", -1)); PRINTF(("%#11x", -1)); PRINTF(("%#12x", -1)); PRINTF(("%#12x, %20x, %2x, %42x", -1, 3, 30, -1)); PRINTF(("%#12x, %x, %2x, %42x", -1, 3, 30, -1)); PRINTF(("%#14x%#20x%#2x%#x", -1, 3, 30, -1)); PRINTF(("%#14xc%#20xs%#2xX%#xi", -1, 3, 30, -1)); PRINTF(("%#1.x", 0)); PRINTF(("%#1.0x", 0)); PRINTF(("%#2.0x", 0)); PRINTF(("%#3.0x", 0)); PRINTF(("%#1.1x", 0)); PRINTF(("%#1.2x", 0)); PRINTF(("%#1.3x", 0)); PRINTF(("%#1.0x", 4)); PRINTF(("%#1.1x", 4)); PRINTF(("%#1.2x", 4)); PRINTF(("%#1.3x", 4)); PRINTF(("%#10.20x", 42)); PRINTF(("%#42.2x", 42000)); PRINTF(("%#42.20x", 42000)); PRINTF(("%#42.42x", 42000)); PRINTF(("%#042.52x", 42000)); PRINTF(("wait for it... %#050.50x", 42)); PRINTF(("%#20.19x is how many tests are going to be made", 8000)); PRINTF(("%#20.20x is how many tests are going to be made", 8000)); PRINTF(("%#20.21x is how many tests are going to be made", 8000)); PRINTF(("%#5x", 2147483647)); PRINTF(("%#30x", 2147483647)); PRINTF(("%#9x", 2147483647)); PRINTF(("%#10x", 2147483647)); PRINTF(("%#11x", 2147483647)); PRINTF(("%#5x", -1)); PRINTF(("%#30x", -1)); PRINTF(("%#10x", -1)); PRINTF(("%#11x", -1)); PRINTF(("%#12x", -1)); PRINTF(("%#12x, %20x, %2x, %000042x", -1, 3, 30, -1)); PRINTF(("%#12x, %x, %002x, %42x", -1, 3, 30, -1)); PRINTF(("%#014.2x%#20x%###2.x%###.5x", -1, 3, 30, -1)); PRINTF(("%#14xc%#20xs%#2xx%#xi", -1, 3, 30, -1)); right_cat = (g_all_bonus & CAT_BONUS_2) ? 1 : test_cat ? (test_cat & CAT_X && test_cat & CAT_BONUS_2) : 1; describe("\n%x, widths, precisions 0 and #"); PRINTF(("%#01x", 0)); PRINTF(("%#01x", -4)); PRINTF(("%#010x", 42)); PRINTF(("%#042x", 42000)); PRINTF(("%#020x", -42000)); PRINTF(("wait for it... %#050x", 42)); PRINTF(("%#020x is how many tests are going to be made", 8000)); PRINTF(("%#05x", 2147483647)); PRINTF(("%#030x", 2147483647)); PRINTF(("%#010x", 2147483647)); PRINTF(("%#05x", -1)); PRINTF(("%#030x", -1)); PRINTF(("%#010x", -1)); PRINTF(("%#011x", -1)); PRINTF(("%#012x", -1)); PRINTF(("%#012x, %20x, %2x, %42x", -1, 3, 30, -1)); PRINTF(("%#012x, %x, %2x, %42x", -1, 3, 30, -1)); PRINTF(("%#014x%#020x%#02x%#0x", -1, 3, 30, -1)); PRINTF(("%#014xc%#020xs%#02xX%#0xi", -1, 3, 30, -1)); PRINTF(("%#01.x", 0)); PRINTF(("%#01.0x", 0)); PRINTF(("%#02.0x", 0)); PRINTF(("%#03.0x", 0)); PRINTF(("%#01.1x", 0)); PRINTF(("%#01.2x", 0)); PRINTF(("%#01.3x", 0)); PRINTF(("%#01.0x", 4)); PRINTF(("%#01.1x", 4)); PRINTF(("%#01.2x", 4)); PRINTF(("%#01.3x", 4)); PRINTF(("%#010.20x", 42)); PRINTF(("%#042.2x", 42000)); PRINTF(("%#042.20x", 42000)); PRINTF(("%#042.42x", 42000)); PRINTF(("%#42.52x", 42000)); PRINTF(("wait for it... %#50.50x", 42)); PRINTF(("%#020.19x is how many tests are going to be made", 8000)); PRINTF(("%#020.20x is how many tests are going to be made", 8000)); PRINTF(("%#020.21x is how many tests are going to be made", 8000)); PRINTF(("%#05x", 2147483647)); PRINTF(("%#030x", 2147483647)); PRINTF(("%#09x", 2147483647)); PRINTF(("%#010x", 2147483647)); PRINTF(("%#011x", 2147483647)); PRINTF(("%#05x", -1)); PRINTF(("%#030x", -1)); PRINTF(("%#010x", -1)); PRINTF(("%#011x", -1)); PRINTF(("%#012x", -1)); PRINTF(("%#012x, %20x, %2x, %000042x", -1, 3, 30, -1)); PRINTF(("%#012x, %x, %002x, %42x", -1, 3, 30, -1)); PRINTF(("%#0014.2x%#020x%#0#0#02.x%#0#0#0.5x", -1, 3, 30, -1)); PRINTF(("%#014xc%#020xs%#02xx%#0xi", -1, 3, 30, -1)); right_cat = (g_all_bonus & CAT_BONUS_2) ? 1 : test_cat ? (test_cat & CAT_X && test_cat & CAT_BONUS_2) : 1; describe("\n%x, widths, precisions, - and #"); PRINTF(("%#-1x", 0)); PRINTF(("%#-1x", -4)); PRINTF(("%#-10x", 42)); PRINTF(("%#-42x", 42000)); PRINTF(("%#-20x", -42000)); PRINTF(("wait for it... %#-50x", 42)); PRINTF(("%#-20x is how many tests are going to be made", 8000)); PRINTF(("%#-5x", 2147483647)); PRINTF(("%#-30x", 2147483647)); PRINTF(("%#-10x", 2147483647)); PRINTF(("%#-5x", -1)); PRINTF(("%#-30x", -1)); PRINTF(("%#-10x", -1)); PRINTF(("%#-11x", -1)); PRINTF(("%#-12x", -1)); PRINTF(("%#-12x, %20x, %2x, %42x", -1, 3, 30, -1)); PRINTF(("%#-12x, %x, %#02x, %#042x", -1, 3, 30, -1)); PRINTF(("%#-14x%020x%02x%0x", -1, 3, 30, -1)); PRINTF(("%#-14xc%020xs%02xx%0xi", -1, 3, 30, -1)); PRINTF(("%#-1.x", 0)); PRINTF(("%#-1.0x", 0)); PRINTF(("%#-2.0x", 0)); PRINTF(("%#-3.0x", 0)); PRINTF(("%#-1.1x", 0)); PRINTF(("%#-1.2x", 0)); PRINTF(("%#-1.3x", 0)); PRINTF(("%#-1.0x", 4)); PRINTF(("%#-1.1x", 4)); PRINTF(("%#-1.3x", 4)); PRINTF(("%#-10.20x", 42)); PRINTF(("%#-42.2x", 42000)); PRINTF(("%#-42.20x", 42000)); PRINTF(("%#-42.42x", 42000)); PRINTF(("%#-42.52x", 42000)); PRINTF(("wait for it... %#-50.50x", 42)); PRINTF(("%#-20.19x is how many tests are going to be made", 8000)); PRINTF(("%#-20.20x is how many tests are going to be made", 8000)); PRINTF(("%#-20.21x is how many tests are going to be made", 8000)); PRINTF(("%#-5x", 2147483647)); PRINTF(("%#-30x", 2147483647)); PRINTF(("%#-9x", 2147483647)); PRINTF(("%#-10x", 2147483647)); PRINTF(("%#-11x", 2147483647)); PRINTF(("%#-5x", -1)); PRINTF(("%#-30x", -1)); PRINTF(("%#-10x", -1)); PRINTF(("%#-11x", -1)); PRINTF(("%#-12x", -1)); PRINTF(("%#-12x, %20x, %2x, %#-#-#-#-42x", -1, 3, 30, -1)); PRINTF(("%#-12x, %x, %#-#-2x, %42x", -1, 3, 30, -1)); PRINTF(("%#-#-14.2x%#-20x%#-#-#-2.x%#-#-#-.5x", -1, 3, 30, -1)); PRINTF(("%#-14xc%-20xs%#-2xX%#-xi", -1, 3, 30, -1)); right_cat = (g_all_bonus & CAT_BONUS_2) ? 1 : test_cat ? (test_cat & CAT_BIG_X && test_cat & CAT_BONUS_2) : 1; describe("\n%X, widths, precisions and #"); PRINTF(("%#1X", 0)); PRINTF(("%#1X", -4)); PRINTF(("%#10X", 42)); PRINTF(("%#42X", 42000)); PRINTF(("%#20X", -42000)); PRINTF(("wait for it... %#50X", 42)); PRINTF(("%#20X is how many tests are going to be made", 8000)); PRINTF(("%#5X", 2147483647)); PRINTF(("%#30X", 2147483647)); PRINTF(("%#10X", 2147483647)); PRINTF(("%#5X", -1)); PRINTF(("%#30X", -1)); PRINTF(("%#10X", -1)); PRINTF(("%#11X", -1)); PRINTF(("%#12X", -1)); PRINTF(("%#12X, %20X, %2X, %42X", -1, 3, 30, -1)); PRINTF(("%#12X, %X, %#2X, %#42X", -1, 3, 30, -1)); PRINTF(("%#14X%020X%02X%0X", -1, 3, 30, -1)); PRINTF(("%#14Xc%020Xs%02XX%0Xi", -1, 3, 30, -1)); PRINTF(("%#1.X", 0)); PRINTF(("%#1.0X", 0)); PRINTF(("%#2.0X", 0)); PRINTF(("%#3.0X", 0)); PRINTF(("%#1.1X", 0)); PRINTF(("%#1.2X", 0)); PRINTF(("%#1.3X", 0)); PRINTF(("%#1.0X", 4)); PRINTF(("%#1.1X", 4)); PRINTF(("%#1.3X", 4)); PRINTF(("%#10.20X", 42)); PRINTF(("%#42.2X", 42000)); PRINTF(("%#42.20X", 42000)); PRINTF(("%#42.42X", 42000)); PRINTF(("%#42.52X", 42000)); PRINTF(("wait for it... %#50.50X", 42)); PRINTF(("%#20.19X is how many tests are going to be made", 8000)); PRINTF(("%#20.20X is how many tests are going to be made", 8000)); PRINTF(("%#20.21X is how many tests are going to be made", 8000)); PRINTF(("%#5X", 2147483647)); PRINTF(("%#30X", 2147483647)); PRINTF(("%#9X", 2147483647)); PRINTF(("%#10X", 2147483647)); PRINTF(("%#11X", 2147483647)); PRINTF(("%#5X", -1)); PRINTF(("%#30X", -1)); PRINTF(("%#10X", -1)); PRINTF(("%#11X", -1)); PRINTF(("%#12X", -1)); PRINTF(("%#12X, %20X, %2X, %####42X", -1, 3, 30, -1)); PRINTF(("%#12X, %X, %##2X, %42X", -1, 3, 30, -1)); PRINTF(("%##14.2X%#20X%###2.X%###.5X", -1, 3, 30, -1)); PRINTF(("%#14Xc%020Xs%#2XX%#Xi", -1, 3, 30, -1)); right_cat = (g_all_bonus & CAT_BONUS_2) ? 1 : test_cat ? (test_cat & CAT_BIG_X && test_cat & CAT_BONUS_2) : 1; describe("\n%X, widths, precisions, 0 and #"); PRINTF(("%#01X", 0)); PRINTF(("%#01X", -4)); PRINTF(("%#010X", 42)); PRINTF(("%#042X", 42000)); PRINTF(("%#020X", -42000)); PRINTF(("wait for it... %#050X", 42)); PRINTF(("%#020X is how many tests are going to be made", 8000)); PRINTF(("%#05X", 2147483647)); PRINTF(("%#030X", 2147483647)); PRINTF(("%#010X", 2147483647)); PRINTF(("%#05X", -1)); PRINTF(("%#030X", -1)); PRINTF(("%#010X", -1)); PRINTF(("%#011X", -1)); PRINTF(("%#012X", -1)); PRINTF(("%#012X, %20X, %2X, %42X", -1, 3, 30, -1)); PRINTF(("%#012X, %X, %#02X, %#042X", -1, 3, 30, -1)); PRINTF(("%#014X%020X%02X%0X", -1, 3, 30, -1)); PRINTF(("%#014Xc%020Xs%02XX%0Xi", -1, 3, 30, -1)); PRINTF(("%#01.X", 0)); PRINTF(("%#01.0X", 0)); PRINTF(("%#02.0X", 0)); PRINTF(("%#03.0X", 0)); PRINTF(("%#01.1X", 0)); PRINTF(("%#01.2X", 0)); PRINTF(("%#01.3X", 0)); PRINTF(("%#01.0X", 4)); PRINTF(("%#01.1X", 4)); PRINTF(("%#01.3X", 4)); PRINTF(("%#010.20X", 42)); PRINTF(("%#042.2X", 42000)); PRINTF(("%#042.20X", 42000)); PRINTF(("%#042.42X", 42000)); PRINTF(("%#042.52X", 42000)); PRINTF(("wait for it... %#050.50X", 42)); PRINTF(("%#020.19X is how many tests are going to be made", 8000)); PRINTF(("%#020.20X is how many tests are going to be made", 8000)); PRINTF(("%#020.21X is how many tests are going to be made", 8000)); PRINTF(("%#05X", 2147483647)); PRINTF(("%#030X", 2147483647)); PRINTF(("%#09X", 2147483647)); PRINTF(("%#010X", 2147483647)); PRINTF(("%#011X", 2147483647)); PRINTF(("%#05X", -1)); PRINTF(("%#030X", -1)); PRINTF(("%#010X", -1)); PRINTF(("%#011X", -1)); PRINTF(("%#012X", -1)); PRINTF(("%#012X, %20X, %2X, %#0#0#0#042X", -1, 3, 30, -1)); PRINTF(("%#012X, %X, %#0#02X, %42X", -1, 3, 30, -1)); PRINTF(("%#0#014.2X%#020X%#0#0#02.X%#0#0#0.5X", -1, 3, 30, -1)); PRINTF(("%#014Xc%020Xs%#02XX%#0Xi", -1, 3, 30, -1)); right_cat = (g_all_bonus & CAT_BONUS_2) ? 1 : test_cat ? (test_cat & CAT_BIG_X && test_cat & CAT_BONUS_2) : 1; describe("\n%X, widths, precisions, - and #"); PRINTF(("%#-1X", 0)); PRINTF(("%#-1X", -4)); PRINTF(("%#-10X", 42)); PRINTF(("%#-42X", 42000)); PRINTF(("%#-20X", -42000)); PRINTF(("wait for it... %#-50X", 42)); PRINTF(("%#-20X is how many tests are going to be made", 8000)); PRINTF(("%#-5X", 2147483647)); PRINTF(("%#-30X", 2147483647)); PRINTF(("%#-10X", 2147483647)); PRINTF(("%#-5X", -1)); PRINTF(("%#-30X", -1)); PRINTF(("%#-10X", -1)); PRINTF(("%#-11X", -1)); PRINTF(("%#-12X", -1)); PRINTF(("%#-12X, %20X, %2X, %42X", -1, 3, 30, -1)); PRINTF(("%#-12X, %X, %#02X, %#042X", -1, 3, 30, -1)); PRINTF(("%#-14X%020X%02X%0X", -1, 3, 30, -1)); PRINTF(("%#-14Xc%020Xs%02XX%0Xi", -1, 3, 30, -1)); PRINTF(("%#-1.X", 0)); PRINTF(("%#-1.0X", 0)); PRINTF(("%#-2.0X", 0)); PRINTF(("%#-3.0X", 0)); PRINTF(("%#-1.1X", 0)); PRINTF(("%#-1.2X", 0)); PRINTF(("%#-1.3X", 0)); PRINTF(("%#-1.0X", 4)); PRINTF(("%#-1.1X", 4)); PRINTF(("%#-1.3X", 4)); PRINTF(("%#-10.20X", 42)); PRINTF(("%#-42.2X", 42000)); PRINTF(("%#-42.20X", 42000)); PRINTF(("%#-42.42X", 42000)); PRINTF(("%#-42.52X", 42000)); PRINTF(("wait for it... %#-50.50X", 42)); PRINTF(("%#-20.19X is how many tests are going to be made", 8000)); PRINTF(("%#-20.20X is how many tests are going to be made", 8000)); PRINTF(("%#-20.21X is how many tests are going to be made", 8000)); PRINTF(("%#-5X", 2147483647)); PRINTF(("%#-30X", 2147483647)); PRINTF(("%#-9X", 2147483647)); PRINTF(("%#-10X", 2147483647)); PRINTF(("%#-11X", 2147483647)); PRINTF(("%#-5X", -1)); PRINTF(("%#-30X", -1)); PRINTF(("%#-10X", -1)); PRINTF(("%#-11X", -1)); PRINTF(("%#-12X", -1)); PRINTF(("%#-12X, %20X, %2X, %#-#-#-#-42X", -1, 3, 30, -1)); PRINTF(("%#-12X, %X, %#-#-2X, %42X", -1, 3, 30, -1)); PRINTF(("%#-#-14.2X%#-20X%#-#-#-2.X%#-#-#-.5X", -1, 3, 30, -1)); PRINTF(("%#-14Xc%-20Xs%#-2XX%#-Xi", -1, 3, 30, -1)); right_cat = (g_all_bonus & CAT_BONUS_2) ? 1 : test_cat ? (test_cat & CAT_D && test_cat & CAT_BONUS_2) : 1; describe("\n%d, widths, precisions and ' '"); PRINTF(("% d", 0)); PRINTF(("% d", 1)); PRINTF(("% d", -1)); PRINTF(("% d", 0)); PRINTF(("% d", 1)); PRINTF(("% d", -1)); PRINTF(("% d", 2147483647)); PRINTF(("% d", (int)-2147483648)); PRINTF(("% d", 2147483647)); PRINTF(("% d", (int)-2147483648)); PRINTF(("% d", 2178647)); PRINTF(("% d", (int)-2144348)); PRINTF(("% d", 2147837)); PRINTF(("% d", (int)-2147486)); PRINTF(("% 1d", 0)); PRINTF(("% 1d", -1)); PRINTF(("% 2d", 1)); PRINTF(("% 3d", -1)); PRINTF(("% 4d", 0)); PRINTF(("% 5d", 1)); PRINTF(("% 2d", -1)); PRINTF(("% 9d", 2147483647)); PRINTF(("% 10d", 2147483647)); PRINTF(("% 11d", 2147483647)); PRINTF(("% 9d", (int)-2147483648)); PRINTF(("% 10d", (int)-2147483648)); PRINTF(("% 11d", (int)-2147483648)); PRINTF(("% 11d", (int)-2147483648)); PRINTF(("% 12d", (int)-2147483648)); PRINTF(("% .d", 0)); PRINTF(("% .0d", 0)); PRINTF(("% .1d", 0)); PRINTF(("% .2d", 0)); PRINTF(("% .0d", 1)); PRINTF(("% .1d", 1)); PRINTF(("% .d", -1)); PRINTF(("% .3d", 1)); PRINTF(("% .1d", -1)); PRINTF(("% .3d", -1)); PRINTF(("% .10d", 2147483647)); PRINTF(("% .11d", 2147483647)); PRINTF(("% .9d", (int)-2147483648)); PRINTF(("% .9d", 2147483647)); PRINTF(("% .10d", (int)-2147483648)); PRINTF(("% .8d", 2178647)); PRINTF(("% .9d", (int)-2144348)); PRINTF(("% .7d", 2147837)); PRINTF(("% .8d", (int)-2147486)); PRINTF(("% .7d", (int)-2147486)); PRINTF(("% 1.0d", 0)); PRINTF(("% 1.1d", 0)); PRINTF(("% 1.2d", 0)); PRINTF(("% 1.1d", -1)); PRINTF(("% 1.2d", -1)); PRINTF(("% 2.0d", 1)); PRINTF(("% 3.3d", -1)); PRINTF(("% 4.8d", 0)); PRINTF(("% 5.d", 1)); PRINTF(("% 2.9d", -1)); PRINTF(("% 9.8d", 2147483647)); PRINTF(("% 10.11d", 2147483647)); PRINTF(("% 11.9d", 2147483647)); PRINTF(("% 9.9d", (int)-2147483648)); PRINTF(("% 10.9d", (int)-2147483648)); PRINTF(("% 11.9di", (int)-2147483648)); PRINTF(("% 11.12ds", (int)-2147483648)); PRINTF(("% 12.0d", (int)-2147483648)); PRINTF(("life % 12.0d is %d craz% dy", 1, 2, (int)-2147483648)); PRINTF(("% 9.12d is % 22d craz%22dy", -333, 2, -30)); PRINTF(("Thank % d you vim for allowing % .dme ed% dit this file", -333, 0, -30)); right_cat = (g_all_bonus & CAT_BONUS_2) ? 1 : test_cat ? (test_cat & CAT_D && test_cat & CAT_BONUS_2) : 1; describe("\n%d, widths, precisions, ' ' and 0"); PRINTF(("%0 d", 0)); PRINTF(("%0 d", 1)); PRINTF(("%0 d", -1)); PRINTF(("%0 d", 0)); PRINTF(("%0 d", 1)); PRINTF(("%0 d", -1)); PRINTF(("%0 d", 2147483647)); PRINTF(("%0 d", (int)-2147483648)); PRINTF(("%0 d", 2147483647)); PRINTF(("%0 d", (int)-2147483648)); PRINTF(("%0 d", 2178647)); PRINTF(("%0 d", (int)-2144348)); PRINTF(("%0 d", 2147837)); PRINTF(("%0 d", (int)-2147486)); PRINTF(("%0 1d", 0)); PRINTF(("%0 1d", -1)); PRINTF(("%0 2d", 1)); PRINTF(("%0 3d", -1)); PRINTF(("%0 4d", 0)); PRINTF(("%0 5d", 1)); PRINTF(("%0 2d", -1)); PRINTF(("%0 9d", 2147483647)); PRINTF(("%0 10d", 2147483647)); PRINTF(("%0 11d", 2147483647)); PRINTF(("%0 13d", 2147483647)); PRINTF(("%0 16d", 2147483647)); PRINTF(("%0 9d", (int)-2147483648)); PRINTF(("%0 10d", (int)-2147483648)); PRINTF(("%0 11d", (int)-2147483648)); PRINTF(("%0 11d", (int)-2147483648)); PRINTF(("%0 12d", (int)-2147483648)); PRINTF(("%0 .d", 0)); PRINTF(("%0 .0d", 0)); PRINTF(("%0 .1d", 0)); PRINTF(("%0 .2d", 0)); PRINTF(("%0 .0d", 1)); PRINTF(("%0 .1d", 1)); PRINTF(("%0 .d", -1)); PRINTF(("%0 .3d", 1)); PRINTF(("%0 .1d", -1)); PRINTF(("%0 .3d", -1)); PRINTF(("%0 .10d", 2147483647)); PRINTF(("%0 .11d", 2147483647)); PRINTF(("%0 .12d", 2147483647)); PRINTF(("%0 .9d", (int)-2147483648)); PRINTF(("%0 .9d", 2147483647)); PRINTF(("%0 .10d", (int)-2147483648)); PRINTF(("%0 .8d", 2178647)); PRINTF(("%0 .9d", (int)-2144348)); PRINTF(("%0 .7d", 2147837)); PRINTF(("%0 .8d", (int)-2147486)); PRINTF(("%0 .7d", (int)-2147486)); PRINTF(("%0 1.0d", 0)); PRINTF(("%0 1.1d", 0)); PRINTF(("%0 1.2d", 0)); PRINTF(("%0 1.1d", -1)); PRINTF(("%0 1.2d", -1)); PRINTF(("%0 2.0d", 1)); PRINTF(("%0 3.3d", -1)); PRINTF(("%0 0 0 4.8d", 0)); PRINTF(("%0 5.d", 1)); PRINTF(("%0 2.9d", -1)); PRINTF(("%0 9.8d", 2147483647)); PRINTF(("%0 10.11d", 2147483647)); PRINTF(("%0 11.9d", 2147483647)); PRINTF(("%0 9.9d", (int)-2147483648)); PRINTF(("%0 10.9d", (int)-2147483648)); PRINTF(("%0 11.9di", (int)-2147483648)); PRINTF(("%0 11.12ds", (int)-2147483648)); PRINTF(("%0 12.0d", (int)-2147483648)); PRINTF(("life % 0 12.0d is %0d craz% 20dy", 1, 2, (int)-2147483648)); PRINTF(("% 00 00 9.12d is % 22d craz% 022dy", -333, 2, -30)); PRINTF(("Thank % 0 d you vim for allowing % 0 .dme ed% 0 dit this file", -333, 0, -30)); right_cat = (g_all_bonus & CAT_BONUS_2) ? 1 : test_cat ? (test_cat & CAT_D && test_cat & CAT_BONUS_2) : 1; describe("\n%d, widths, precisions, ' ' and -"); PRINTF(("%- d", 0)); PRINTF(("%- d", 1)); PRINTF(("%- d", -1)); PRINTF(("%- d", 0)); PRINTF(("%- d", 1)); PRINTF(("%- d", -1)); PRINTF(("%- d", 2147483647)); PRINTF(("%- d", (int)-2147483648)); PRINTF(("%- d", 2147483647)); PRINTF(("%- d", (int)-2147483648)); PRINTF(("%- d", 2178647)); PRINTF(("%- d", (int)-2144348)); PRINTF(("%- d", 2147837)); PRINTF(("%- d", (int)-2147486)); PRINTF(("%- 1d", 0)); PRINTF(("%- 1d", -1)); PRINTF(("%- 2d", 1)); PRINTF(("%- 3d", -1)); PRINTF(("%- 4d", 0)); PRINTF(("%- 5d", 1)); PRINTF(("%- 2d", -1)); PRINTF(("%- 9d", 2147483647)); PRINTF(("%- 10d", 2147483647)); PRINTF(("%- 11d", 2147483647)); PRINTF(("%- 13d", 2147483647)); PRINTF(("%- 16d", 2147483647)); PRINTF(("%- 9d", (int)-2147483648)); PRINTF(("%- 10d", (int)-2147483648)); PRINTF(("%- 11d", (int)-2147483648)); PRINTF(("%- 11d", (int)-2147483648)); PRINTF(("%- 12d", (int)-2147483648)); PRINTF(("%- .d", 0)); PRINTF(("%- .0d", 0)); PRINTF(("%- .1d", 0)); PRINTF(("%- .2d", 0)); PRINTF(("%- .0d", 1)); PRINTF(("%- .1d", 1)); PRINTF(("%- .d", -1)); PRINTF(("%- .3d", 1)); PRINTF(("%- .1d", -1)); PRINTF(("%- .3d", -1)); PRINTF(("%- .10d", 2147483647)); PRINTF(("%- .11d", 2147483647)); PRINTF(("%- .12d", 2147483647)); PRINTF(("%- .9d", (int)-2147483648)); PRINTF(("%- .9d", 2147483647)); PRINTF(("%- .10d", (int)-2147483648)); PRINTF(("%- .8d", 2178647)); PRINTF(("%- .9d", (int)-2144348)); PRINTF(("%- .7d", 2147837)); PRINTF(("%- .8d", (int)-2147486)); PRINTF(("%- .7d", (int)-2147486)); PRINTF(("%- 1.0d", 0)); PRINTF(("%- 1.1d", 0)); PRINTF(("%- 1.2d", 0)); PRINTF(("%- 1.1d", -1)); PRINTF(("%- 1.2d", -1)); PRINTF(("%- 2.0d", 1)); PRINTF(("%- 3.3d", -1)); PRINTF(("%- 4.8d", 0)); PRINTF(("%- 5.d", 1)); PRINTF(("%- 2.9d", -1)); PRINTF(("%- 9.8d", 2147483647)); PRINTF(("%- 10.11d", 2147483647)); PRINTF(("%- 11.9d", 2147483647)); PRINTF(("%- 9.9d", (int)-2147483648)); PRINTF(("%- - 10.9d", (int)-2147483648)); PRINTF(("%- 11.9dx", (int)-2147483648)); PRINTF(("%- 11.12ds", (int)-2147483648)); PRINTF(("%- 12.0d", (int)-2147483648)); PRINTF(("life % - 12.0d is %-d craz% 20dy", 1, 2, (int)-2147483648)); PRINTF(("% 00 00 9.12d is % - 22d craz%-- -22dy", -333, 2, -30)); PRINTF(("Thank % - d you vim for allowing % 0 .dme ed% - dit this file", -333, 0, -30)); right_cat = (g_all_bonus & CAT_BONUS_2) ? 1 : test_cat ? (test_cat & CAT_I && test_cat & CAT_BONUS_2) : 1; describe("\n%d, widths, precisions and ' '"); PRINTF(("% i", 0)); PRINTF(("% i", 1)); PRINTF(("% i", -1)); PRINTF(("% i", 0)); PRINTF(("% i", 1)); PRINTF(("% i", -1)); PRINTF(("% i", 2147483647)); PRINTF(("% i", (int)-2147483648)); PRINTF(("% i", 2147483647)); PRINTF(("% i", (int)-2147483648)); PRINTF(("% i", 2178647)); PRINTF(("% i", (int)-2144348)); PRINTF(("% i", 2147837)); PRINTF(("% i", (int)-2147486)); PRINTF(("% 1i", 0)); PRINTF(("% 1i", -1)); PRINTF(("% 2i", 1)); PRINTF(("% 3i", -1)); PRINTF(("% 4i", 0)); PRINTF(("% 5i", 1)); PRINTF(("% 2i", -1)); PRINTF(("% 9i", 2147483647)); PRINTF(("% 10i", 2147483647)); PRINTF(("% 11i", 2147483647)); PRINTF(("% 9i", (int)-2147483648)); PRINTF(("% 10i", (int)-2147483648)); PRINTF(("% 11i", (int)-2147483648)); PRINTF(("% 11i", (int)-2147483648)); PRINTF(("% 12i", (int)-2147483648)); PRINTF(("% .i", 0)); PRINTF(("% .0i", 0)); PRINTF(("% .1i", 0)); PRINTF(("% .2i", 0)); PRINTF(("% .0i", 1)); PRINTF(("% .1i", 1)); PRINTF(("% .i", -1)); PRINTF(("% .3i", 1)); PRINTF(("% .1i", -1)); PRINTF(("% .3i", -1)); PRINTF(("% .10i", 2147483647)); PRINTF(("% .11i", 2147483647)); PRINTF(("% .9i", (int)-2147483648)); PRINTF(("% .9i", 2147483647)); PRINTF(("% .10i", (int)-2147483648)); PRINTF(("% .8i", 2178647)); PRINTF(("% .9i", (int)-2144348)); PRINTF(("% .7i", 2147837)); PRINTF(("% .8i", (int)-2147486)); PRINTF(("% .7i", (int)-2147486)); PRINTF(("% 1.0i", 0)); PRINTF(("% 1.1i", 0)); PRINTF(("% 1.2i", 0)); PRINTF(("% 1.1i", -1)); PRINTF(("% 1.2i", -1)); PRINTF(("% 2.0i", 1)); PRINTF(("% 3.3i", -1)); PRINTF(("% 4.8i", 0)); PRINTF(("% 5.i", 1)); PRINTF(("% 2.9i", -1)); PRINTF(("% 9.8i", 2147483647)); PRINTF(("% 10.11i", 2147483647)); PRINTF(("% 11.9i", 2147483647)); PRINTF(("% 9.9i", (int)-2147483648)); PRINTF(("% 10.9i", (int)-2147483648)); PRINTF(("% 11.9ii", (int)-2147483648)); PRINTF(("% 11.12is", (int)-2147483648)); PRINTF(("% 12.0i", (int)-2147483648)); PRINTF(("life % 12.0i is %i craz% iy", 1, 2, (int)-2147483648)); PRINTF(("% 9.12i is % 22i craz%22iy", -333, 2, -30)); PRINTF(("Thank % i you vim for allowing % .ime ed% iit this file", -333, 0, -30)); right_cat = (g_all_bonus & CAT_BONUS_2) ? 1 : test_cat ? (test_cat & CAT_I && test_cat & CAT_BONUS_2) : 1; describe("\n%i, widths, precisions, ' ' and 0"); PRINTF(("%0 i", 0)); PRINTF(("%0 i", 1)); PRINTF(("%0 i", -1)); PRINTF(("%0 i", 0)); PRINTF(("%0 i", 1)); PRINTF(("%0 i", -1)); PRINTF(("%0 i", 2147483647)); PRINTF(("%0 i", (int)-2147483648)); PRINTF(("%0 i", 2147483647)); PRINTF(("%0 i", (int)-2147483648)); PRINTF(("%0 i", 2178647)); PRINTF(("%0 i", (int)-2144348)); PRINTF(("%0 i", 2147837)); PRINTF(("%0 i", (int)-2147486)); PRINTF(("%0 1i", 0)); PRINTF(("%0 1i", -1)); PRINTF(("%0 2i", 1)); PRINTF(("%0 3i", -1)); PRINTF(("%0 4i", 0)); PRINTF(("%0 5i", 1)); PRINTF(("%0 2i", -1)); PRINTF(("%0 9i", 2147483647)); PRINTF(("%0 10i", 2147483647)); PRINTF(("%0 11i", 2147483647)); PRINTF(("%0 13i", 2147483647)); PRINTF(("%0 16i", 2147483647)); PRINTF(("%0 9i", (int)-2147483648)); PRINTF(("%0 10i", (int)-2147483648)); PRINTF(("%0 11i", (int)-2147483648)); PRINTF(("%0 11i", (int)-2147483648)); PRINTF(("%0 12i", (int)-2147483648)); PRINTF(("%0 .i", 0)); PRINTF(("%0 .0i", 0)); PRINTF(("%0 .1i", 0)); PRINTF(("%0 .2i", 0)); PRINTF(("%0 .0i", 1)); PRINTF(("%0 .1i", 1)); PRINTF(("%0 .i", -1)); PRINTF(("%0 .3i", 1)); PRINTF(("%0 .1i", -1)); PRINTF(("%0 .3i", -1)); PRINTF(("%0 .10i", 2147483647)); PRINTF(("%0 .11i", 2147483647)); PRINTF(("%0 .12i", 2147483647)); PRINTF(("%0 .9i", (int)-2147483648)); PRINTF(("%0 .9i", 2147483647)); PRINTF(("%0 .10i", (int)-2147483648)); PRINTF(("%0 .8i", 2178647)); PRINTF(("%0 .9i", (int)-2144348)); PRINTF(("%0 .7i", 2147837)); PRINTF(("%0 .8i", (int)-2147486)); PRINTF(("%0 .7i", (int)-2147486)); PRINTF(("%0 1.0i", 0)); PRINTF(("%0 1.1i", 0)); PRINTF(("%0 1.2i", 0)); PRINTF(("%0 1.1i", -1)); PRINTF(("%0 1.2i", -1)); PRINTF(("%0 2.0i", 1)); PRINTF(("%0 3.3i", -1)); PRINTF(("%0 0 0 4.8i", 0)); PRINTF(("%0 5.i", 1)); PRINTF(("%0 2.9i", -1)); PRINTF(("%0 9.8i", 2147483647)); PRINTF(("%0 10.11i", 2147483647)); PRINTF(("%0 11.9i", 2147483647)); PRINTF(("%0 9.9i", (int)-2147483648)); PRINTF(("%0 10.9i", (int)-2147483648)); PRINTF(("%0 11.9ii", (int)-2147483648)); PRINTF(("%0 11.12is", (int)-2147483648)); PRINTF(("%0 12.0i", (int)-2147483648)); PRINTF(("life % 0 12.0i is %0i craz% 20iy", 1, 2, (int)-2147483648)); PRINTF(("% 00 00 9.12i is % 22i craz% 022iy", -333, 2, -30)); PRINTF(("Thank % 0 i you vim for allowing % 0 .ime ei% 0 iit this file", -333, 0, -30)); right_cat = (g_all_bonus & CAT_BONUS_2) ? 1 : test_cat ? (test_cat & CAT_I && test_cat & CAT_BONUS_2) : 1; describe("\n%i, widths, precisions, ' ' and -"); PRINTF(("%- i", 0)); PRINTF(("%- i", 1)); PRINTF(("%- i", -1)); PRINTF(("%- i", 0)); PRINTF(("%- i", 1)); PRINTF(("%- i", -1)); PRINTF(("%- i", 2147483647)); PRINTF(("%- i", (int)-2147483648)); PRINTF(("%- i", 2147483647)); PRINTF(("%- i", (int)-2147483648)); PRINTF(("%- i", 2178647)); PRINTF(("%- i", (int)-2144348)); PRINTF(("%- i", 2147837)); PRINTF(("%- i", (int)-2147486)); PRINTF(("%- 1i", 0)); PRINTF(("%- 1i", -1)); PRINTF(("%- 2i", 1)); PRINTF(("%- 3i", -1)); PRINTF(("%- 4i", 0)); PRINTF(("%- 5i", 1)); PRINTF(("%- 2i", -1)); PRINTF(("%- 9i", 2147483647)); PRINTF(("%- 10i", 2147483647)); PRINTF(("%- 11i", 2147483647)); PRINTF(("%- 13i", 2147483647)); PRINTF(("%- 16i", 2147483647)); PRINTF(("%- 9i", (int)-2147483648)); PRINTF(("%- 10i", (int)-2147483648)); PRINTF(("%- 11i", (int)-2147483648)); PRINTF(("%- 11i", (int)-2147483648)); PRINTF(("%- 12i", (int)-2147483648)); PRINTF(("%- .i", 0)); PRINTF(("%- .0i", 0)); PRINTF(("%- .1i", 0)); PRINTF(("%- .2i", 0)); PRINTF(("%- .0i", 1)); PRINTF(("%- .1i", 1)); PRINTF(("%- .i", -1)); PRINTF(("%- .3i", 1)); PRINTF(("%- .1i", -1)); PRINTF(("%- .3i", -1)); PRINTF(("%- .10i", 2147483647)); PRINTF(("%- .11i", 2147483647)); PRINTF(("%- .12i", 2147483647)); PRINTF(("%- .9i", (int)-2147483648)); PRINTF(("%- .9i", 2147483647)); PRINTF(("%- .10i", (int)-2147483648)); PRINTF(("%- .8i", 2178647)); PRINTF(("%- .9i", (int)-2144348)); PRINTF(("%- .7i", 2147837)); PRINTF(("%- .8i", (int)-2147486)); PRINTF(("%- .7i", (int)-2147486)); PRINTF(("%- 1.0i", 0)); PRINTF(("%- 1.1i", 0)); PRINTF(("%- 1.2i", 0)); PRINTF(("%- 1.1i", -1)); PRINTF(("%- 1.2i", -1)); PRINTF(("%- 2.0i", 1)); PRINTF(("%- 3.3i", -1)); PRINTF(("%- 4.8i", 0)); PRINTF(("%- 5.i", 1)); PRINTF(("%- 2.9i", -1)); PRINTF(("%- 9.8i", 2147483647)); PRINTF(("%- 10.11i", 2147483647)); PRINTF(("%- 11.9i", 2147483647)); PRINTF(("%- 9.9i", (int)-2147483648)); PRINTF(("%- - 10.9i", (int)-2147483648)); PRINTF(("%- 11.9ii", (int)-2147483648)); PRINTF(("%- 11.12is", (int)-2147483648)); PRINTF(("%- 12.0i", (int)-2147483648)); PRINTF(("life % - 12.0i is %-i craz% 20iy", 1, 2, (int)-2147483648)); PRINTF(("% 00 00 9.12i is % - 22i craz%-- -22iy", -333, 2, -30)); PRINTF(("Thank % - i you vim for allowing % 0 .ime ed% - ixt this file", -333, 0, -30)); right_cat = (g_all_bonus & CAT_BONUS_2) ? 1 : test_cat ? (test_cat & CAT_D && test_cat & CAT_BONUS_2) : 1; describe("\n%d, widths, precisions and ' '"); PRINTF(("%+d", 0)); PRINTF(("%+d", 1)); PRINTF(("%+d", -1)); PRINTF(("%++++d", 0)); PRINTF(("%+++d", 1)); PRINTF(("%++d", -1)); PRINTF(("%+d", 2147483647)); PRINTF(("%+d", (int)-2147483648)); PRINTF(("%+++d", 2147483647)); PRINTF(("%++d", (int)-2147483648)); PRINTF(("%+d", 2178647)); PRINTF(("%+d", (int)-2144348)); PRINTF(("%+++d", 2147837)); PRINTF(("%++d", (int)-2147486)); PRINTF(("%+1d", 0)); PRINTF(("%++1d", -1)); PRINTF(("%+2d", 1)); PRINTF(("%+3d", -1)); PRINTF(("%++++4d", 0)); PRINTF(("%+++5d", 1)); PRINTF(("%++2d", -1)); PRINTF(("%+9d", 2147483647)); PRINTF(("%+10d", 2147483647)); PRINTF(("%+11d", 2147483647)); PRINTF(("%+9d", (int)-2147483648)); PRINTF(("%+++10d", (int)-2147483648)); PRINTF(("%++11d", (int)-2147483648)); PRINTF(("%++11d", (int)-2147483648)); PRINTF(("%+++++12d", (int)-2147483648)); PRINTF(("%+.d", 0)); PRINTF(("%+.0d", 0)); PRINTF(("%+.1d", 0)); PRINTF(("%+.2d", 0)); PRINTF(("%+.0d", 1)); PRINTF(("%+.1d", 1)); PRINTF(("%+.d", -1)); PRINTF(("%+++.3d", 1)); PRINTF(("%++.1d", -1)); PRINTF(("%++.3d", -1)); PRINTF(("%+.10d", 2147483647)); PRINTF(("%+.11d", 2147483647)); PRINTF(("%+.9d", (int)-2147483648)); PRINTF(("%+++.9d", 2147483647)); PRINTF(("%++.10d", (int)-2147483648)); PRINTF(("%+.8d", 2178647)); PRINTF(("%+.9d", (int)-2144348)); PRINTF(("%+++.7d", 2147837)); PRINTF(("%++.8d", (int)-2147486)); PRINTF(("%++.7d", (int)-2147486)); PRINTF(("%+1.0d", 0)); PRINTF(("%+1.1d", 0)); PRINTF(("%+1.2d", 0)); PRINTF(("%++1.1d", -1)); PRINTF(("%++1.2d", -1)); PRINTF(("%+2.0d", 1)); PRINTF(("%+3.3d", -1)); PRINTF(("%++++4.8d", 0)); PRINTF(("%++5.d", 1)); PRINTF(("%++2.9d", -1)); PRINTF(("%+9.8d", 2147483647)); PRINTF(("%+10.11d", 2147483647)); PRINTF(("%+11.9d", 2147483647)); PRINTF(("%+9.9d", (int)-2147483648)); PRINTF(("%+++10.9d", (int)-2147483648)); PRINTF(("%++11.9di", (int)-2147483648)); PRINTF(("%++11.12ds", (int)-2147483648)); PRINTF(("%+++12.0d", (int)-2147483648)); PRINTF(("life %+++12.0d is %d craz%+dy", 1, 2, (int)-2147483648)); PRINTF(("%+++9.12d is % 22d craz%22dy", -333, 2, -30)); PRINTF(("Thank %++d you vim for allowing %+.dme ed%+++++dit this file", -333, 0, -30)); right_cat = (g_all_bonus & CAT_BONUS_2) ? 1 : test_cat ? (test_cat & CAT_D && test_cat & CAT_BONUS_2) : 1; describe("\n%d, widths, precisions, ' ' and 0"); PRINTF(("%0+d", 0)); PRINTF(("%0+d", 1)); PRINTF(("%0+d", -1)); PRINTF(("%0++++d", 0)); PRINTF(("%0+++d", 1)); PRINTF(("%0++d", -1)); PRINTF(("%0+d", 2147483647)); PRINTF(("%0+d", (int)-2147483648)); PRINTF(("%0+++d", 2147483647)); PRINTF(("%0++d", (int)-2147483648)); PRINTF(("%0+d", 2178647)); PRINTF(("%0+d", (int)-2144348)); PRINTF(("%0+++d", 2147837)); PRINTF(("%0++d", (int)-2147486)); PRINTF(("%0+1d", 0)); PRINTF(("%0++1d", -1)); PRINTF(("%0+2d", 1)); PRINTF(("%0+3d", -1)); PRINTF(("%0++++4d", 0)); PRINTF(("%0+++5d", 1)); PRINTF(("%0++2d", -1)); PRINTF(("%0+9d", 2147483647)); PRINTF(("%0+10d", 2147483647)); PRINTF(("%0+11d", 2147483647)); PRINTF(("%0+13d", 2147483647)); PRINTF(("%0+16d", 2147483647)); PRINTF(("%0+9d", (int)-2147483648)); PRINTF(("%0+++10d", (int)-2147483648)); PRINTF(("%0++11d", (int)-2147483648)); PRINTF(("%0++11d", (int)-2147483648)); PRINTF(("%0+++++12d", (int)-2147483648)); PRINTF(("%0+.d", 0)); PRINTF(("%0+.0d", 0)); PRINTF(("%0+.1d", 0)); PRINTF(("%0+.2d", 0)); PRINTF(("%0+.0d", 1)); PRINTF(("%0+.1d", 1)); PRINTF(("%0+.d", -1)); PRINTF(("%0+++.3d", 1)); PRINTF(("%0++.1d", -1)); PRINTF(("%0++.3d", -1)); PRINTF(("%0+.10d", 2147483647)); PRINTF(("%0+.11d", 2147483647)); PRINTF(("%0+.12d", 2147483647)); PRINTF(("%0+.9d", (int)-2147483648)); PRINTF(("%0+++.9d", 2147483647)); PRINTF(("%0++.10d", (int)-2147483648)); PRINTF(("%0+.8d", 2178647)); PRINTF(("%0+.9d", (int)-2144348)); PRINTF(("%0+++.7d", 2147837)); PRINTF(("%0++.8d", (int)-2147486)); PRINTF(("%0++.7d", (int)-2147486)); PRINTF(("%0+1.0d", 0)); PRINTF(("%0+1.1d", 0)); PRINTF(("%0+1.2d", 0)); PRINTF(("%0++1.1d", -1)); PRINTF(("%0++1.2d", -1)); PRINTF(("%0+2.0d", 1)); PRINTF(("%0+3.3d", -1)); PRINTF(("%0+0++0+4.8d", 0)); PRINTF(("%0++5.d", 1)); PRINTF(("%0++2.9d", -1)); PRINTF(("%0+9.8d", 2147483647)); PRINTF(("%0+10.11d", 2147483647)); PRINTF(("%0+11.9d", 2147483647)); PRINTF(("%0+9.9d", (int)-2147483648)); PRINTF(("%0+++10.9d", (int)-2147483648)); PRINTF(("%0++11.9di", (int)-2147483648)); PRINTF(("%0++11.12ds", (int)-2147483648)); PRINTF(("%0+++12.0d", (int)-2147483648)); PRINTF(("life %++0++12.0d is %0d craz%+20dy", 1, 2, (int)-2147483648)); PRINTF(("%++00+00+9.12d is %++22d craz%+022dy", -333, 2, -30)); PRINTF(("Thank %++0+d you vim for allowing %+0+++.dme ed%++0+dit this file", -333, 0, -30)); right_cat = (g_all_bonus & CAT_BONUS_2) ? 1 : test_cat ? (test_cat & CAT_D && test_cat & CAT_BONUS_2) : 1; describe("\n%d, widths, precisions, ' ' and -"); PRINTF(("%-+d", 0)); PRINTF(("%-+d", 1)); PRINTF(("%-+d", -1)); PRINTF(("%-++++d", 0)); PRINTF(("%-+++d", 1)); PRINTF(("%-++d", -1)); PRINTF(("%-+d", 2147483647)); PRINTF(("%-+d", (int)-2147483648)); PRINTF(("%-+++d", 2147483647)); PRINTF(("%-++d", (int)-2147483648)); PRINTF(("%-+d", 2178647)); PRINTF(("%-+d", (int)-2144348)); PRINTF(("%-+++d", 2147837)); PRINTF(("%-++d", (int)-2147486)); PRINTF(("%-+1d", 0)); PRINTF(("%-++1d", -1)); PRINTF(("%-+2d", 1)); PRINTF(("%-+3d", -1)); PRINTF(("%-++++4d", 0)); PRINTF(("%-+++5d", 1)); PRINTF(("%-++2d", -1)); PRINTF(("%-+9d", 2147483647)); PRINTF(("%-+10d", 2147483647)); PRINTF(("%-+11d", 2147483647)); PRINTF(("%-+13d", 2147483647)); PRINTF(("%-+16d", 2147483647)); PRINTF(("%-+9d", (int)-2147483648)); PRINTF(("%-+++10d", (int)-2147483648)); PRINTF(("%-++11d", (int)-2147483648)); PRINTF(("%-++11d", (int)-2147483648)); PRINTF(("%-+++++12d", (int)-2147483648)); PRINTF(("%-+.d", 0)); PRINTF(("%-+.0d", 0)); PRINTF(("%-+.1d", 0)); PRINTF(("%-+.2d", 0)); PRINTF(("%-+.0d", 1)); PRINTF(("%-+.1d", 1)); PRINTF(("%-+.d", -1)); PRINTF(("%-+++.3d", 1)); PRINTF(("%-++.1d", -1)); PRINTF(("%-++.3d", -1)); PRINTF(("%-+.10d", 2147483647)); PRINTF(("%-+.11d", 2147483647)); PRINTF(("%-+.12d", 2147483647)); PRINTF(("%-+.9d", (int)-2147483648)); PRINTF(("%-+++.9d", 2147483647)); PRINTF(("%-++.10d", (int)-2147483648)); PRINTF(("%-+.8d", 2178647)); PRINTF(("%-+.9d", (int)-2144348)); PRINTF(("%-+++.7d", 2147837)); PRINTF(("%-++.8d", (int)-2147486)); PRINTF(("%-++.7d", (int)-2147486)); PRINTF(("%-+1.0d", 0)); PRINTF(("%-+1.1d", 0)); PRINTF(("%-+1.2d", 0)); PRINTF(("%-++1.1d", -1)); PRINTF(("%-++1.2d", -1)); PRINTF(("%-+2.0d", 1)); PRINTF(("%-+3.3d", -1)); PRINTF(("%-++++4.8d", 0)); PRINTF(("%-++5.d", 1)); PRINTF(("%-++2.9d", -1)); PRINTF(("%-+9.8d", 2147483647)); PRINTF(("%-+10.11d", 2147483647)); PRINTF(("%-+11.9d", 2147483647)); PRINTF(("%-+9.9d", (int)-2147483648)); PRINTF(("%-++-+10.9d", (int)-2147483648)); PRINTF(("%-++11.9dx", (int)-2147483648)); PRINTF(("%-++11.12ds", (int)-2147483648)); PRINTF(("%-+++12.0d", (int)-2147483648)); PRINTF(("life %++-++12.0d is %-d craz%+20dy", 1, 2, (int)-2147483648)); PRINTF(("%++00+00+9.12d is %++-+22d craz%--+-22dy", -333, 2, -30)); PRINTF(("Thank %++-+d you vim for allowing %+0+++.dme ed%++-+dit this file", -333, 0, -30)); return (0); } ================================================ FILE: src/user_printer.c ================================================ ================================================ FILE: src/utils.c ================================================ #include "get_next_line.h" #include "libftprintf.h" #include "../libtest/libtest.h" #include "ft_printf_tester.h" #include "helpers.h" #include #include #include extern int g_current_test; extern int g_test_nbr; extern int passed_tests; void pretty_printf(char *params) { int i = 0; int inside_string = 0; tester_putstr(BLUE "ft_printf" RESET); while (params[i]) { if (params[i] == '"' || params[i] == '\'') { if (inside_string) tester_putchar(params[i]), tester_putstr(RESET), inside_string = 0; else tester_putstr(GREEN), tester_putchar(params[i]), inside_string = 1; } else if (isdigit(params[i]) && !inside_string) { if (!isdigit(params[i - 1])) tester_putstr(YELLOW); tester_putchar(params[i]); } else { if (i > 0 && isdigit(params[i - 1]) && !inside_string) tester_putstr(RESET); tester_putchar(params[i]); } i++; } tester_putstr(";\n"); } int already_printed_help = 0; void print_help(char *params_used) { if (already_printed_help) return ; already_printed_help = 1; tester_putstr("\n "); tester_putstr(RESET BOLD "You can rerun this test with " RESET YELLOW "sh test "); tester_putnbr(g_current_test); tester_putstr(RESET "\n "); tester_putstr("The function was called like this:\n "); pretty_printf(params_used); } void print_output(t_result *expected, t_result *user, unsigned int expected_size, unsigned int result_size) //void print_string_diff(char expected[], char result[], unsigned int expected_size, unsigned int result_size) { int is_red_already = 0; tester_putstr(RESET " Expected: ["); for (unsigned int i = 0; i < expected_size; i++) { if (expected->output_str[i] == '\0') tester_putstr(MAGENTA "\\0" RESET); else if (expected->output_str[i] == '\n') tester_putstr(MAGENTA "\\n" RESET); else if (!isprint(expected->output_str[i])) print_non_print(expected->output_str[i]); else tester_putchar(expected->output_str[i]); } tester_putstr("], return: "); tester_putnbr(expected->return_value); tester_putstr("\n Got: ["); unsigned int i = 0; int expected_ended = 0; while (i < result_size) { if (expected_ended || ((expected->output_str[i] != user->output_str[i]) && !is_red_already)) { is_red_already = 1; tester_putstr(BOLD RED); } else if (expected->output_str[i] == user->output_str[i] && is_red_already) { tester_putstr(RESET); is_red_already = 0; } if (user->output_str[i] == '\0') tester_putstr(BOLD MAGENTA "\\0" RESET); else if (user->output_str[i] > 1 && user->output_str[i] < 32) print_non_print(user->output_str[i]); else tester_putchar(user->output_str[i]); if (!expected_ended && expected->output_str[i] == '\0') expected_ended = 1; i++; } tester_putstr(RESET "], return: "); tester_putnbr(user->return_value); } int check_leaks_sanitizer(int user_stderr) { int n = 0; int error = 0; char *line; int result = get_next_line(user_stderr, &line); // get rid of the first line free(line); if (result <= 0) return (0); result = get_next_line(user_stderr, &line); n = strlen(line); if (tester_strnstr(line, "heap-buffer-overflow", n)) { error = ERRORS_BUFFER_OVERFLOW; } free(line); result = get_next_line(user_stderr, &line); // get rid of the first line n = strlen(line); if (tester_strnstr(line, "leaks", n)) error = ERRORS_LEAK; else if (tester_strnstr(line, "SEGV", n)) error = ERRORS_SIGSEGV; free(line); // get rid of the rest of the file char dummy_buffer[100]; while (read(user_stderr, dummy_buffer, 100)); get_next_line(user_stderr, &line); free(line); return (error); } int check_leaks_malloc_count(int user_stderr) { int result; int leaked = 0; char *line; while (1) { result = get_next_line(user_stderr, &line); if (result <= 0) { free(line); break ; } if (!tester_strnstr(line, "current: 0", tester_strlen(line))) { leaked = 1; } free(line); } return (leaked); } int check_errors(char *params_used) { int error = 0; (void) params_used; int user_stderr = open("files/user_stderr.txt", O_RDONLY); if (LEAK_CHECKER == LEAK_SANITIZER) error = check_leaks_sanitizer(user_stderr); else if (LEAK_CHECKER == MALLOC_COUNT) error = check_leaks_malloc_count(user_stderr); close(user_stderr); return (error); } int g_tests_failed = 0; # define MAX(x, y) ((x > y) ? x : y) int check_result(t_result *user_result, t_result *orig_result, char *params_used) { if (g_current_test == g_test_nbr || g_test_nbr == 0) { char *result; char *expected; int success = 1; int errors = 0; int wrong_return = 0; errors = check_errors(params_used); expected = orig_result->output_str; result = user_result->output_str; if (!errors || errors == ERRORS_LEAK) { success = test_string(expected, result, MAX(orig_result->bytes_read, user_result->bytes_read)); wrong_return = user_result->return_value != orig_result->return_value; } if (success && !wrong_return && !errors) tester_putstr(GREEN); else tester_putstr(BOLD RED "\n "), g_tests_failed++; tester_putnbr(g_current_test); tester_putchar('.'); if (success && !wrong_return && !errors) tester_putstr(BOLD "OK" RESET); else if (errors && errors != ERRORS_LEAK) { if (errors == ERRORS_SIGSEGV || errors == ERRORS_BUFFER_OVERFLOW) tester_putstr(BOLD "SIGSEGV!"); else tester_putstr(BOLD "UNKNOWN CRASH!"); } else tester_putstr("KO"); if (!success) tester_putstr(" (Wrong output)"); if (wrong_return) tester_putstr(" (Wrong return)"); if (errors == ERRORS_LEAK) tester_putstr(RED " (LEAKS!)"); if (!success || wrong_return) { tester_putstr("\n"); print_output(orig_result, user_result, orig_result->bytes_read, user_result->bytes_read); } else tester_putchar(' '); if (!success || errors || wrong_return) print_help(params_used); else passed_tests++; } return (0); } extern int right_cat; void describe(char *test_title) { if (!right_cat || g_test_nbr != 0) return ; tester_putstr(BOLD); tester_putstr(test_title); tester_putstr(": "RESET "\n "); } void open_pipes(int *p1, int *p2) { if (pipe(p1) < 0) { tester_putstr("error opening stdout_pipe\n"); exit(26); } if (pipe(p2) < 0) { tester_putstr("error opening rtrn_pipe\n"); exit(24); } } extern int g_function_return; void prepare_test(char *err_file, int *outpipe, int *retpipe) { /* the child don't need to read anything */ close(outpipe[READ]); close(retpipe[READ]); /* int file = open("files/original_output.txt", O_CREAT | O_WRONLY | O_TRUNC, 0644); */ int err = open(err_file, O_CREAT | O_WRONLY | O_TRUNC, 0644); /* get rid of real printf errors*/ dup2(outpipe[WRITE], 1); dup2(err, 2); g_function_return = -10; } void finish_test(int result, int *outpipe, int *retpipe) { write(retpipe[WRITE], &result, sizeof(int)); close(outpipe[WRITE]); close(retpipe[WRITE]); exit (0); } void fetch_result(t_result *result, char *output_buffer, int *stdout_pipe, int *rtrn_pipe) { close(stdout_pipe[WRITE]); close(rtrn_pipe[WRITE]); int bytes_read = read(stdout_pipe[READ], output_buffer, BUFSIZE); g_function_return = -10; read(rtrn_pipe[READ], &g_function_return, sizeof(int)); close(stdout_pipe[READ]); close(rtrn_pipe[READ]); result->return_value = g_function_return; result->output_str = output_buffer; result->bytes_read = bytes_read; } extern char *g_test_params; extern char *g_user_fake_stdout; void handle_errors(int wstatus, t_result *user_r, t_result *orig_r, char *user_output, int *output_pipe, int *return_pipe) { /* 30 is the status code for the leak sanitizer */ int child_exit_status = WEXITSTATUS(wstatus); if (child_exit_status && child_exit_status != 30) { tester_putstr(BOLD RED); tester_putnbr(g_current_test); switch(child_exit_status) { case SIGSEGV: /* classic segfault */ tester_putstr(".SIGSEGV! " RESET); break; case SIGKILL: /* killed because of timeout */ tester_putstr(".TIMEOUT! " RESET); break; case SIGABRT: tester_putstr(".SIGABRT! " RESET); break ; default: /* something yet to be discovered */ tester_putstr(".CRASH! wstatus: "); tester_putnbr(child_exit_status); tester_putstr(RESET); } print_help(g_test_params); } else { fetch_result(user_r, user_output, output_pipe, return_pipe); check_result(user_r, orig_r, g_test_params); } } ================================================ FILE: test ================================================ #!/bin/sh git pull NOSAN= BONUS= DAT_FEEL=" +⡴⠑⡄⠀⠀⠀⠀⠀⠀⠀ ⣀⣀⣤⣤⣤⣀⡀ +⠸⡇⠀⠿⡀⠀⠀⠀⣀⡴⢿⣿⣿⣿⣿⣿⣿⣿⣷⣦⡀ +⠀⠀⠀⠀⠑⢄⣠⠾⠁⣀⣄⡈⠙⣿⣿⣿⣿⣿⣿⣿⣿⣆ +⠀⠀⠀⠀⢀⡀⠁⠀⠀⠈⠙⠛⠂⠈⣿⣿⣿⣿⣿⠿⡿⢿⣆ +⠀⠀⠀⢀⡾⣁⣀⠀⠴⠂⠙⣗⡀⠀⢻⣿⣿⠭⢤⣴⣦⣤⣹⠀⠀⠀⢀⢴⣶⣆ +⠀⠀⢀⣾⣿⣿⣿⣷⣮⣽⣾⣿⣥⣴⣿⣿⡿⢂⠔⢚⡿⢿⣿⣦⣴⣾⠸⣼⡿ +⠀⢀⡞⠁⠙⠻⠿⠟⠉⠀⠛⢹⣿⣿⣿⣿⣿⣌⢤⣼⣿⣾⣿⡟⠉ +⠀⣾⣷⣶⠇⠀⠀⣤⣄⣀⡀⠈⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇ +⠀⠉⠈⠉⠀⠀⢦⡈⢻⣿⣿⣿⣶⣶⣶⣶⣤⣽⡹⣿⣿⣿⣿⡇ +⠀⠀⠀⠀⠀⠀⠀⠉⠲⣽⡻⢿⣿⣿⣿⣿⣿⣿⣷⣜⣿⣿⣿⡇ +⠀⠀ ⠀⠀⠀⠀⠀⢸⣿⣿⣷⣶⣮⣭⣽⣿⣿⣿⣿⣿⣿⣿⠇ +⠀⠀⠀⠀⠀⠀⣀⣀⣈⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠇ +⠀⠀⠀⠀⠀⠀⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠃ " if [ $# -eq 0 ] || ([ $# -eq 1 ] && [ "$1" = "nosan" ]) then BONUS="bonus" fi for i in $@ do if [ "$i" = "nosan" ] then NOSAN="nosan" fi if [ "$i" = "b" ] || [ "$i" = "b1" ] || [ "$i" = "b2" ] then BONUS="bonus" fi done make ${BONUS}${NOSAN} if [ $? -ne 0 ] then echo -e "\033[1;31m\ncompilation error.\033[0;0m" echo -e "\033[1;32m${DAT_FEEL}\033[0;0m" exit 1 else echo "./tester $@ 2>myleaks.txt" LSAN_OPTIONS=exitcode=30 ./tester $@ 2>myleaks.txt || exit 2 fi