This website houses notes from my studies at the University of Liverpool. If you see any errors or issues, please do open an issue on this site's GitHub.
Testing with setup() & tearDown() We use setUp() and tearDown() to ensure that the tests don’t interfere with each-other. We can implement this, in our testing class, like so: package org.example.antbook.junit; //import JUnit4 classes: import static org.junit.Assert.*; import org.junit.Test; // import org.junit.Before; //import org.junit.* also would work import org.junit.After; //...
Creating Filesets Filesets are a group of files represented like so: <fileset dir="src" includes="**/*.java" id="source.fileset"/> dir - Mandatory attribute to denote a root directory for the fileset. includes - Which files from this directory to include. id - A reference which can be used to call the fileset. We can...
As no data about a client is remembered by default we can’t track a series of requests from coming from the same user. This can be problematic if we want to send several forms, such as on a shopping site. Hidden Inputs One way of solving this is by sending...
Arrays & Pointers Arrays are a sugar for pointer arithmetic. We can emulate this behaviour like so: #include <stdio.h> int main()j { int i; int arr[5] = {1, 2, 3, 4, 5}; int *p = arr; for (i = 0; i < 5; i++) { printf("%d\n", *p); p++; } }...
Datatypes The following datatypes are available in Ant: Paths - An ordered list of files and directories. Classpath is a variant of this. Filesets - A collection of files rooted from a specified directory. Patternsets - A collection of file matching patterns. Filtersets Properties This is a way of defining...
Pointers are a variable holding the address of another variable of the same data type. You can use them to create: Shared variables between different functions without copying. Linked data structures such as linked lists. Addresses vs Pointers You can get the address of a variable using &. You can...
Web Applications using PHP flowchart LR Browser -->|1. Post Action| ws[Web Server] ws -->|2. Process| pp[PHP Processor] pp <-->|3. Store/Retrieve| ds[Database Server] pp -->|4. Merge with HTML| ws ws -->|5. Return HTML| Browser PHP & Forms We can use something like the following to call a php script with the...
Running Time of Divide & Conquer We can use a recurrence relation to analyse the running time where: $T(n)$ denotes the running time on an input of size $n$. We can then extend this with a case statement that relates $T(n)$ to values of the function $T$ for problem sizes...
Boundary Testing This is where we test: One Above One Below and on the value of a boundary. Orthogonal Testing Tests should only test a single possible bug. For example we could have two tests: One if the input is too long. One if the input is too short. We...
PHP uses PCRE (Perl-compatible regular expressions). You can try out your expressions in a live environment at regex101 (ensure that PCRE2 is checked). PHP RE Syntax We can use the following syntax to define regular expressions in PHP: '/a*bc/' The expression is enclosed in two /. Quantifiers We can request...