Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add conditionals go file and call functions top down in workshop_test…
… go file.
- Loading branch information
Showing
4 changed files
with
76 additions
and
7 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package workshop | ||
|
||
import ( | ||
"math" | ||
"strconv" | ||
) | ||
|
||
func conditionals() { | ||
var str string | ||
flag := true | ||
|
||
if flag { | ||
str = "Righteous Path" | ||
} | ||
assert(str == "Righteous Path") | ||
|
||
var value int | ||
if value < 10 { | ||
value = 10 | ||
} | ||
assert(value == 10) | ||
|
||
value2 := 7 | ||
if value2 > 10 { | ||
value2++ | ||
} else { | ||
value2-- | ||
} | ||
assert(value2 == 6) | ||
|
||
const movie = "Rocky" | ||
var score int | ||
if movie == "Rambo" { | ||
score = 9 | ||
} else if movie == "Rocky" { | ||
score = 10 | ||
} else { | ||
score = 6 | ||
} | ||
assert(score == 10) | ||
|
||
const food = "Pizza" | ||
var drink string | ||
switch food { | ||
case "Fries": | ||
drink = "Coke" | ||
case "Sandwich": | ||
drink = "Sprite" | ||
default: | ||
drink = "Milkshake" | ||
} | ||
assert(drink == "Milkshake") | ||
|
||
rem := math.Mod(6, 5) == 1 | ||
assert(rem == true) | ||
|
||
num := "5" | ||
otherNum, err := strconv.Atoi(num) | ||
if err == nil { | ||
otherNum-- | ||
} | ||
assert(otherNum == 4) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package workshop | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
) | ||
|
||
func TestConditionals(t *testing.T) { | ||
variables() | ||
conditionals() | ||
|
||
fmt.Printf("\n%c[32;1mCongratulations you completed the Workshop!!!%c[0m\n\n", 27, 27) | ||
} |