Skip to content

Commit

Permalink
Add conditionals go file and call functions top down in workshop_test…
Browse files Browse the repository at this point in the history
… go file.
  • Loading branch information
jbelmont committed Mar 20, 2017
1 parent c0f764e commit cd1ff44
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 7 deletions.
File renamed without changes.
63 changes: 63 additions & 0 deletions conditionals.go
@@ -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)
}
7 changes: 0 additions & 7 deletions variables_test.go

This file was deleted.

13 changes: 13 additions & 0 deletions workshop_test.go
@@ -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)
}

0 comments on commit cd1ff44

Please sign in to comment.