Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tsuzukihashi committed Jun 18, 2023
1 parent 3ba0d45 commit 4db86aa
Showing 1 changed file with 41 additions and 42 deletions.
83 changes: 41 additions & 42 deletions Tests/NeumorphismUITests/ColorExtensionsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,47 @@ import SwiftUI
@testable import NeumorphismUI

@available(iOS 13.0, *)
@available(macOS 12.0, *)
class ColorExtensiontests: XCTestCase {

var color: Color!

override func setUp() {
color = Color(hex: "000000")
}

func test_init() {
XCTAssertEqual(color.description.dropFirst(), "000000FF")
}

func test_getRGBA() {
let (red, green, blue, alpha) = color.getRGBA()
XCTAssertEqual(red, 0.0)
XCTAssertEqual(green, 0.0)
XCTAssertEqual(blue, 0.0)
XCTAssertEqual(alpha, 1.0)
}

func test_getHSLA() {
let (hue, saturation, lightness, alpha) = color.getHSLA()
XCTAssertEqual(hue, 0.0)
XCTAssertEqual(saturation, 0.0)
XCTAssertEqual(lightness, 0.0)
XCTAssertEqual(alpha, 1.0)
}

// https://uxdesign.cc/neumorphism-in-user-interfaces-b47cef3bf3a6
func test_lighterColor() {
color = Color(hex: "E0E5EC")

let lightColor = color.lighterColor()

XCTAssertEqual(lightColor.description.dropFirst(), "FFFFFFFF")
}

func test_darkerColor() {
color = Color(hex: "E0E5EC")

let darkerColor = color.darkerColor()

XCTAssertEqual(darkerColor.description.dropFirst(), "A1B0C5FF")
}
var color: Color!

override func setUp() {
color = Color(hex: "010101")
}

func test_init() {
XCTAssertEqual(color.description.dropFirst(), "010101FF")
}

func test_getRGBA() {
let (red, green, blue, alpha) = color.getRGBA()
XCTAssertEqual(red, 0.00392156862745098)
XCTAssertEqual(green, 0.00392156862745098)
XCTAssertEqual(blue, 0.00392156862745098)
XCTAssertEqual(alpha, 1.0)
}

func test_getHSLA() {
let (hue, saturation, lightness, alpha) = color.getHSLA()
XCTAssertEqual(hue, 0.0)
XCTAssertEqual(saturation, 0.0)
XCTAssertEqual(lightness, 0.00392156862745098)
XCTAssertEqual(alpha, 1.0)
}

// https://uxdesign.cc/neumorphism-in-user-interfaces-b47cef3bf3a6
func test_lighterColor() {
let lightColor = color.lighterColor()

XCTAssertEqual(lightColor.description.dropFirst(), "202020FF")
}

func test_darkerColor() {
color = Color(hex: "E0E5EC")

let darkerColor = color.darkerColor()

XCTAssertEqual(darkerColor.description.dropFirst(), "A1B0C5FF")
}
}

0 comments on commit 4db86aa

Please sign in to comment.