Code Monkey home page Code Monkey logo

printf-tests's Introduction

printf Tests

Copyright © 2013 Bart Massey

This project is an attempt to pull together various printf(3) tests from free and open source software projects and compile them into a single language-independent file that is at least nearly equal to the sum of its parts.

The principal source file here is printf-tests.txt. The format of this file is

    exclusion serial result format-string arg1 arg2 ...

The exclusion is optional, and if present indicates a list of languages that should ignore this test. The exclusions are alphabetic and preceded by "!". Currently, one can exclude C with "C" or Haskell with "H".

The serial number is just that. The result and format strings are string literals in C syntax; the result may be just the literal character ?, in which case printf is expected to fail. The arguments are string, character or numeric literals in C syntax, or pointer literals with the syntax V for a 32-bit pointer or VL for a 64-bit pointer. Fields are separated by space characters: there are deliberately no tab characters in the file. Blank lines and lines beginning with "#" are to be ignored.

String literals deliberately do not contain double-quote characters or backslash escapes, to make them easier to deal with. As a result, all strings can be collected by simply reading from the starting quote to the ending quote. Similarly, all numbers are in decimal.

There are two obvious ways to use these tests. The first way is to simply build a program that reads in and executes each test and checks the result, all at runtime. The second way is to build a program that parses the tests and generates a program in the target language that can be run to execute the tests. The second way is sometimes easier.

Included in this distro is a Haskell program (gen-testcases.hs in the drivers directory) that can be used to generate testcase files for C and Haskell. In drivers/c and drivers/haskell are test drivers that use this infrastructure. The Haskell driver tests Text.Printf. To run all this, first "make" in the drivers subdirectory, and then again in the subdirectory for each driver.

This work is licensed under the GPL version 2: please see the file COPYING in this distribution for license terms. It draws upon sources that are either GPL v2 or under licenses compatible with GPL v2. Please see the sources directory of this distribution for original sources and their licenses, as the license history is too complicated to bear repeating here.

printf-tests's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

0x0584 pm100

printf-tests's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.