\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{swugtd} \pdfinfo{ /Title (ghunit.pdf) /Creator (Cheatography) /Author (swugtd) /Subject (GHUnit Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{1F49D1} \definecolor{LightBackground}{HTML}{F1F3FC} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{GHUnit Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{swugtd} via \textcolor{DarkBackground}{\uline{cheatography.com/2076/cs/597/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}swugtd \\ \uline{cheatography.com/swugtd} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 12th May, 2016.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Example}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{// For iOS \newline % Row Count 1 (+ 1) \#import \textless{}GHUnitIOS/GHUnit.h\textgreater{} \newline % Row Count 2 (+ 1) // For Mac OS X \newline % Row Count 3 (+ 1) //\#import \textless{}GHUnit/GHUnit.h\textgreater{} \newline % Row Count 4 (+ 1) @interface ExampleTest : GHTestCase \{ \} \newline % Row Count 5 (+ 1) @end \newline % Row Count 6 (+ 1) @implementation ExampleTest \newline % Row Count 7 (+ 1) - \seqsplit{(BOOL)shouldRunOnMainThread} \{ \newline % Row Count 8 (+ 1) // By default NO, but if you have a UI test or test dependent on running on the main thread return YES. \newline % Row Count 11 (+ 3) // Also an async test that calls back on the main thread, you'll probably want to return YES. \newline % Row Count 13 (+ 2) return NO; \newline % Row Count 14 (+ 1) \} \newline % Row Count 15 (+ 1) - (void)setUpClass \{ \newline % Row Count 16 (+ 1) // Run at start of all tests in the class \newline % Row Count 17 (+ 1) \} \newline % Row Count 18 (+ 1) - (void)tearDownClass \{ \newline % Row Count 19 (+ 1) // Run at end of all tests in the class \newline % Row Count 20 (+ 1) \} \newline % Row Count 21 (+ 1) - (void)setUp \{ \newline % Row Count 22 (+ 1) // Run before each test method \newline % Row Count 23 (+ 1) \} \newline % Row Count 24 (+ 1) - (void)tearDown \{ \newline % Row Count 25 (+ 1) // Run after each test method \newline % Row Count 26 (+ 1) \} \newline % Row Count 27 (+ 1) - (void)testFoo \{ \newline % Row Count 28 (+ 1) NSString *a = @"foo"; \newline % Row Count 29 (+ 1) GHTestLog(@"I can log to the GHUnit test console: \%@", a); \newline % Row Count 31 (+ 2) } \tn \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Example (cont)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{ // Assert a is not NULL, with no custom error description \newline % Row Count 2 (+ 2) GHAssertNotNULL(a, nil); \newline % Row Count 3 (+ 1) // Assert equal objects, add custom error description \newline % Row Count 5 (+ 2) NSString *b = @"bar"; \newline % Row Count 6 (+ 1) GHAssertEqualObjects(a, b, @"A custom error message. a should be equal to: \%@.", b); \newline % Row Count 8 (+ 2) \} \newline % Row Count 9 (+ 1) - (void)testBar \{ \newline % Row Count 10 (+ 1) // Another test \newline % Row Count 11 (+ 1) \} \newline % Row Count 12 (+ 1) @end% Row Count 13 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Assert Macros}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{GHAssertNoErr}} (a1, description, ...) \newline % Row Count 1 (+ 1) {\bf{GHAssertErr}} (a1, a2, description, ...) \newline % Row Count 2 (+ 1) {\bf{GHAssertNotNULL}} ** (a1, description, ...) \newline % Row Count 3 (+ 1) {\bf{GHAssertNULL}} (a1, description, ...) \newline % Row Count 4 (+ 1) {\bf{GHAssertNotEquals}} (a1, a2, description, ...) \newline % Row Count 5 (+ 1) {\bf{GHAssertNotEqualObjects}} (a1, a2, desc, ...) \newline % Row Count 6 (+ 1) {\bf{GHAssertOperation}} (a1, a2, op, description, ...) \newline % Row Count 8 (+ 2) {\bf{GHAssertGreaterThan}} (a1, a2, description, ...) \newline % Row Count 10 (+ 2) {\bf{GHAssertGreaterThanOrEqual}} (a1, a2, description, ...) \newline % Row Count 12 (+ 2) {\bf{GHAssertLessThan}} (a1, a2, description, ...) \newline % Row Count 13 (+ 1) {\bf{GHAssertLessThanOrEqual}} (a1, a2, description, ...) \newline % Row Count 15 (+ 2) {\bf{GHAssertEqualStrings}} (a1, a2, description, ...) \newline % Row Count 17 (+ 2) {\bf{GHAssertNotEqualStrings}} (a1, a2, description, ...) \newline % Row Count 19 (+ 2) {\bf{GHAssertEqualCStrings}} (a1, a2, description, ...) \newline % Row Count 21 (+ 2) {\bf{GHAssertNotEqualCStrings}} (a1, a2, description, ...) \newline % Row Count 23 (+ 2) {\bf{GHAssertEqualObjects}} (a1, a2, description, ...) \newline % Row Count 25 (+ 2) {\bf{GHAssertEquals}} (a1, a2, description, ...)% Row Count 26 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Running from the Command Line}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Copy RunTests.sh and RunIPhoneSecurityd.sh into your project in the same directory as the xcodeproj file. \newline % Row Count 3 (+ 3) | \newline % Row Count 4 (+ 1) |For the script enter: sh RunTests.sh% Row Count 5 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Assert Macros (cont.)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{GHAbsoluteDifference}} (left,right) (MAX(left,right)-MIN(left,right)) \newline % Row Count 2 (+ 2) {\bf{GHAssertEqualsWithAccuracy}} (a1, a2, accuracy, description, ...) \newline % Row Count 4 (+ 2) {\bf{GHFail}} (description, ...) \newline % Row Count 5 (+ 1) {\bf{GHAssertNil}} (a1, description, ...) \newline % Row Count 6 (+ 1) {\bf{GHAssertNotNil}} (a1, description, ...) \newline % Row Count 7 (+ 1) {\bf{GHAssertTrue}} (expr, description, ...) \newline % Row Count 8 (+ 1) {\bf{GHAssertTrueNoThrow}} (expr, description, ...) \newline % Row Count 9 (+ 1) {\bf{GHAssertFalse}} (expr, description, ...) \newline % Row Count 10 (+ 1) {\bf{GHAssertFalseNoThrow}} (expr, description, ...) \newline % Row Count 11 (+ 1) {\bf{GHAssertThrows}} (expr, description, ...) \newline % Row Count 12 (+ 1) {\bf{GHAssertThrowsSpecific}} (expr, specificException, description, ...) \newline % Row Count 14 (+ 2) {\bf{GHAssertThrowsSpecificNamed}} (expr, specificException, aName, description, ...) \newline % Row Count 16 (+ 2) {\bf{GHAssertNoThrow}} (expr, description, ...) \newline % Row Count 17 (+ 1) {\bf{GHAssertNoThrowSpecific}} (expr, specificException, description, ...) \newline % Row Count 19 (+ 2) {\bf{GHAssertNoThrowSpecificNamed}} (expr, specificException, aName, description, ...)% Row Count 21 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \columnbreak \begin{tabularx}{5.377cm}{x{1.34379 cm} x{3.63321 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Environment Variables}} \tn % Row 0 \SetRowColor{LightBackground} TEST & To run a specific test (from the command line). Use \seqsplit{TEST="GHSlowTest/testSlowA"} for a specific test or TEST="GHSlowTest" for a test case \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} \seqsplit{GHUNIT\_RERAISE} & Default NO; If an exception is encountered it re-raises it allowing you to crash into the debugger \tn % Row Count 9 (+ 4) % Row 2 \SetRowColor{LightBackground} \seqsplit{GHUNIT\_AUTORUN} & Default NO; If YES, tests will start automatically \tn % Row Count 11 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{GHUNIT\_AUTOEXIT} & Default NO; If YES, will exit upon test completion (no matter what). For command line MacOSX testing \tn % Row Count 15 (+ 4) % Row 4 \SetRowColor{LightBackground} \seqsplit{GHUNIT\_CLI} & Default NO; Specifies that the tests are being run from the command line. For command line MacOSX testing \tn % Row Count 19 (+ 4) % Row 5 \SetRowColor{white} \seqsplit{WRITE\_JUNIT\_XML} & Default NO; Whether to write out JUnit XML output. For Jenkins CI integration \tn % Row Count 22 (+ 3) % Row 6 \SetRowColor{LightBackground} \seqsplit{JUNIT\_XML\_DIR} & Default to temporary directory. Specify to have files written to a different directory. For Jenkins CI integration. \tn % Row Count 26 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}