Algorithms and OOD (CSC 207 2014S) : EBoards

CSC207.01 2014S, Class 04: Unit Testing





What's the normal order of operations in git?

git status - Figure out what you've modified.

git diff FILE - Figure out how a file has changed.

git add FILE - Indicate which files you want to commit

git status - Figure out what you've modified.

git commit - Commit those files, along with a message.

git status (optional) - Make sure it succeeded

git log (optional) - Review changes


git push - Send everything back to the server

How do I use vi?

vi is a modal editor. That means that you are either in insert mode (the mode in which you insert information) or editing mode (the mode in which you modify what's there or otherwise issue commands).

i puts you insert mode at the current location. Type while in insert mode.

The escape key gets you out of insert mode.

:wq saves and quits. (:w just saves, :q just quits)

Suppose I don't want to pop up an editor while using git commit. What should I do?

git commit -m "Message"

(Last semester, I said that I liked to open the editor each time. I've now gotten used to using -m.)

A few thoughts on testing

An example: Testing exponentiation

   * Compute x^n
   * @pre
   *   n > 0
   *   x^n < Integer.MAX_VALUE
   *   x^n > Integer.MIN_VALUE
  expt(int x, int n)

Suggested tests


Important lesson 1: You need @Test before any test you want to conduct.

Important lesson 2: Documentation is online at

Copyright (c) 2013-14 Samuel A. Rebelsky.

Creative Commons License

This work is licensed under a Creative Commons Attribution 3.0 Unported License. To view a copy of this license, visit or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.