PFT in 42FileChecker - gavinfielder/pft GitHub Wiki
(PFT is not yet integrated into 42FileChecker -- this page is for planning, and is public so that others may discuss it)
PFT is a regression testing utility designed to be used in development of ft_printf. Its test library is modeled on the specification given by the subject pdf, and is much more stringent than moulinette so that cadets have the best possible idea of what their ft_printf is capable of and what it is not. 42FileChecker is a 'final check' tester of 42 projects, and is typically used to determine whether projects sufficiently meet the requirements prior to submission. PFT adds many test cases for ft_printf that are not available in the other modules of 42FileChecker, but the default configuration is arguably too strict as a final check test suite.
For this reason, a separate configuration for 42FileChecker is packaged. Users of 42FileChecker do not have to do anything extra to use it: 42FileChecker switches to this configuration by default.
Below is a minimum mandatory specification for ft_printf that shall determine which tests to have enabled by default in the 42fc configuration of PFT.
Minimal ft_printf specification tested by 42fc configuration of PFT
The intent of this minimal specification is that by meeting this specification, you should be guaranteed to pass moulinette. If you have a trace that implies something in particular needs to be added to it, please contact me so that I can edit this specification.
In the list below, any test cases labeled NOT TESTED has been explicitly disabled in the 42fc configuration. This does not imply such test cases are not mandatory by the rules of the subject, but are merely presumed to not be necessary to pass moulinette.
Some specifications call for behavior according to lab computers on your campus. This is because there are tests in the moul_
block (originally obtained from outdated moulinette test files) that test behavior that has no defined behavior as per printf(3)
, and may be implementation-dependent. It is presumed that moulinette still tests some of these behaviors regardless whether or not any such case should be considered undefined behavior.
The images are taken from this spreadsheet and are intended to be a summary and illustration of the textual specification. If there are inconsistencies, refer to the textual specification (and let me know so that I may correct it).
General / all conversions
- Return value is ignored (as of the time of writing this, moulinette ignores return value)
- Must work with string literals on either side of conversion
- Must work as 'just' a conversion, with no string literal on either side of conversion
- Must work with any other conversion coming before it in the conversion order
%%
Percent Literal - NOT TESTED: with field width and left-justify
%c
Char Conversion - Must handle field width eg
%5c
and left-justify eg%-5c
- Must not segfault with left-justify with no field width eg
%-c
- Must be able to print any 0-255 ascii value, including nonprintable characters and
\0
- Must mirror the system's
printf(3)
's handling of values outside 0-255 range for lab computers on your campus. - Must not segfault with
#
,0
,+
, '
%s
String Conversion - Must handle field width eg
%5s
and left-justify eg%-5s
- Must not segfault with left-justify with no field width eg
%-s
- Must handle precision with precision values above the string length, exactly the string length, and below the string length
- Must handle all possible combinations of precision, field width, and left-justify.
- Must not segfault with
#
,0
,+
, or '
%p
Memory Address Conversion - Must handle field width eg
%5p
and left-justify eg%-5p
- Must not segfault with left-justify with no field width eg
%-p
- Must handle null pointers
- Must not segfault with
#
,0
,+
, '
%d
, %i
Signed Integer Conversion - Must handle negative, positive, and zero numbers.
- Must handle positive, negative, and zero numbers with any combination of field widths and left-justify with widths less than, equal to, and greater than the resultant converted length
- Must not segfault with left-justify with no field width eg
%-d
- Must handle positive, negative, and zero numbers with any combination of precisions less than, equal to, and greater than the resultant converted length
- Must handle any combination of field width, left-justify, and precision
- Must handle
hh
,h
,l
,ll
size modifiers for negative, positive, and zero numbers.- With precision
- With field width and left-justify
- Must not segfault if more than one size modifier is given
- Must handle
+
:- With positive, negative, and zero numbers
- With positive, negative, and zero numbers and any combination of field width and left-justify
- With positive, negative, and zero numbers and precision less than, equal to, and greater than the resultant length
- NOT TESTED: combinations with size modifiers
- Must handle '
- With positive, negative, and zero numbers
- With positive, negative, and zero numbers and any combination of field width and left-justify
- With positive, negative, and zero numbers and precision less than, equal to, and greater than the resultant length
- Must be ignored with
+
- NOT TESTED: combinations with size modifiers
- Must handle
0
:- With any combination of positive, negative, and zero numbers with field width less than, equal to, and greater than the resultant converted length
- Must be ignored with
-
- Must be ignored with precision
- Must not segfault when field width is not given
- NOT TESTED: combinations with spacepad '
- NOT TESTED: combinations with
+
- NOT TESTED: combinations with size modifiers
- Must not segfault with
#
%o
Octal conversion - Must handle positive and zero numbers.
- Must handle positive and zero numbers with any combination of field widths and left-justify with widths less than, equal to, and greater than the resultant converted length
- Must not segfault with left-justify with no field width eg
%-o
- Must handle positive and zero numbers with any combination of precisions less than, equal to, and greater than the resultant converted length
- Must handle any combination of field width, left-justify, and precision
- Must handle
hh
,h
,l
,ll
for positive and zero numbers.- With precision
- With field width and left-justify
- Must not segfault if more than one size modifier given
- Must handle
0
:- With any combination of positive and zero numbers with field width less than, equal to, and greater than the resultant converted length
- Must be ignored with
-
- Must be ignored with precision
- Must not segfault when field width is not given
- NOT TESTED: combinations with size modifiers
- NOT TESTED: combinations with
#
- Must handle
#
:- With any combination of positive and zero numbers with field width less than, equal to, and greater than the resultant converted length
- NOT TESTED: combinations with precision
- NOT TESTED: combinations with size modifiers
- Must mirror the system's
printf(3)
's handling of negative numbers for lab computers on your campus.
%u
Unsigned Integer Conversion - Must handle positive and zero numbers.
- Must handle positive and zero numbers with any combination of field widths and left-justify with widths less than, equal to, and greater than the resultant converted length
- Must not segfault with left-justify with no field width eg
%-u
- Must handle positive and zero numbers with any combination of precisions less than, equal to, and greater than the resultant converted length
- Must handle any combination of field width, left-justify, and precision
- Must handle
hh
,h
,l
,ll
for positive and zero numbers.- With precision
- With field width and left-justify
- Must not segfault if more than one size modifier given
- Must handle
0
:- With any combination of positive and zero numbers with field width less than, equal to, and greater than the resultant converted length
- Must be ignored with
-
- Must be ignored with precision
- Must not segfault when field width is not given
- NOT TESTED: combinations with size modifiers
- Must mirror the system's
printf(3)
's handling of negative numbers for lab computers on your campus.
%x
, %X
Hexadecimal Conversion - Must handle positive and zero numbers.
- Must handle positive and zero numbers with any combination of field widths and left-justify with widths less than, equal to, and greater than the resultant converted length
- Must not segfault with left-justify with no field width eg
%-x
- Must handle positive and zero numbers with any combination of precisions less than, equal to, and greater than the resultant converted length
- Must handle any combination of field width, left-justify, and precision
- Must handle
hh
,h
,l
,ll
for positive and zero numbers.- With precision
- With field width and left-justify
- Must not segfault if more than one size modifier given
- Must handle
0
:- With any combination of positive and zero numbers with field width less than, equal to, and greater than the resultant converted length
- Must be ignored with
-
- Must be ignored with precision
- Must not segfault when field width is not given
- NOT TESTED: combinations with size modifiers
- Must handle
#
:- With any combination of positive and zero numbers with field width less than, equal to, and greater than the resultant converted length
- NOT TESTED: combinations with precision
- NOT TESTED: combinations with size modifiers
- NOT TESTED: combinations with
0
- Must mirror the system's
printf(3)
's handling of negative numbers for lab computers on your campus.
%f
Floating-Point Conversion - Must handle negative, positive, and zero numbers.
- Must handle positive, negative, and zero numbers with any combination of field widths and left-justify with widths less than, equal to, and greater than the resultant converted length
- Must not segfault with left-justify with no field width eg
%-f
- Must handle precision up to 8 decimal places.
- Including implicit zero precision, and explicit zero precision
- Must handle all combinations of the prior required field width, left-justify, and precision.
- Must handle
l
andL
- With precision
- With field width and left-justify
- With any combination of precision and field width and left-justify
- Must not segfault if more than one size modifier is given
- Must handle
+
:- With positive, negative, and zero numbers
- With positive, negative, and zero numbers and any combination of field width and left-justify
- With field width and
0
for widths less than, equal to, and greater than the resultant length - NOT TESTED: combinations with size modifiers
- NOT TESTED: combinations with precision
- NOT TESTED: combinations with
#
- NOT TESTED: combinations with
0
- Must handle '
- With positive, negative, and zero numbers
- With positive, negative, and zero numbers and any combination of field width and left-justify
- With positive, negative, and zero numbers and precision less than, equal to, and greater than the resultant length
- With field width and
0
for widths less than, equal to, and greater than the resultant length - Ignored with
+
- NOT TESTED: combinations with size modifiers
- NOT TESTED: combinations with
#
- NOT TESTED: combinations with
0
- Must handle
0
:- With any combination of positive, negative, and zero numbers with field width less than, equal to, and greater than the resultant converted length
- Must be ignored with
-
- Must not segfault when field width is not given
- NOT TESTED: combinations with size modifiers
- NOT TESTED: combinations with precision
- NOT TESTED: combinations with
#
- Must handle
#
:- With default precision and precision 0
- With size modifiers
- NOT TESTED: with field width and left-justify
- NOT TESTED: reserved values
inf
-inf
, negative zero,NaN
(also disabled by default in PFT default configuration)