| 1 |
// |
| 2 |
// Copyright (c) 2016-2022 The Aurora Authors. All rights reserved. |
| 3 |
// This program is free software. It comes without any warranty, |
| 4 |
// to the extent permitted by applicable law. You can redistribute |
| 5 |
// it and/or modify it under the terms of the Unlicense. See LICENSE |
| 6 |
// file for more details or see below. |
| 7 |
// |
| 8 |
|
| 9 |
// |
| 10 |
// This is free and unencumbered software released into the public domain. |
| 11 |
// |
| 12 |
// Anyone is free to copy, modify, publish, use, compile, sell, or |
| 13 |
// distribute this software, either in source code form or as a compiled |
| 14 |
// binary, for any purpose, commercial or non-commercial, and by any |
| 15 |
// means. |
| 16 |
// |
| 17 |
// In jurisdictions that recognize copyright laws, the author or authors |
| 18 |
// of this software dedicate any and all copyright interest in the |
| 19 |
// software to the public domain. We make this dedication for the benefit |
| 20 |
// of the public at large and to the detriment of our heirs and |
| 21 |
// successors. We intend this dedication to be an overt act of |
| 22 |
// relinquishment in perpetuity of all present and future rights to this |
| 23 |
// software under copyright law. |
| 24 |
// |
| 25 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 26 |
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 27 |
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 28 |
// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 29 |
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 30 |
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 31 |
// OTHER DEALINGS IN THE SOFTWARE. |
| 32 |
// |
| 33 |
// For more information, please refer to <http://unlicense.org/> |
| 34 |
// |
| 35 |
|
| 36 |
package aurora |
| 37 |
|
| 38 |
import ( |
| 39 |
"testing" |
| 40 |
|
| 41 |
"github.com/stretchr/testify/assert" |
| 42 |
) |
| 43 |
|
| 44 |
func testFunc(t *testing.T, name string, v Value, clr Color) { |
| 45 |
t.Helper() |
| 46 |
if str, ok := v.Value().(string); !ok { |
| 47 |
t.Errorf("%s wrong value type: %t, expected string", name, v.Value()) |
| 48 |
} else if str != "x" { |
| 49 |
t.Errorf("%s wrong value: '%v', expected 'x'", name, v.Value()) |
| 50 |
} |
| 51 |
if !isColor(v, clr) { |
| 52 |
t.Errorf("%s wrong color: %d, want: %d", name, v.Color(), clr) |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
func Test_Reset(t *testing.T) { |
| 57 |
testFunc(t, "Reset", Reset("x"), 0) |
| 58 |
testFunc(t, "Complex Reset", Reset(DoublyUnderline(Underline("x"))), |
| 59 |
0) |
| 60 |
} |
| 61 |
|
| 62 |
func Test_Clear(t *testing.T) { |
| 63 |
testFunc(t, "Clear", Clear("x"), 0) |
| 64 |
testFunc(t, "Complex Clear", Clear(DoublyUnderline(Underline("x"))), |
| 65 |
0) |
| 66 |
} |
| 67 |
|
| 68 |
func Test_Bold(t *testing.T) { |
| 69 |
testFunc(t, "Bold", Bold("x"), BoldFm) |
| 70 |
testFunc(t, "Complex Bold", Bold(Italic(Red("x"))), |
| 71 |
ItalicFm|RedFg|BoldFm) |
| 72 |
} |
| 73 |
|
| 74 |
func Test_Faint(t *testing.T) { |
| 75 |
testFunc(t, "Faint", Faint("x"), FaintFm) |
| 76 |
testFunc(t, "Complex Faint", Faint(BrightBlack("x").BgBrightGreen()), |
| 77 |
BrightFg|BlackFg|FaintFm|BrightBg|GreenBg) |
| 78 |
} |
| 79 |
|
| 80 |
func Test_DoublyUnderline(t *testing.T) { |
| 81 |
testFunc(t, "DoublyUnderline", DoublyUnderline("x"), DoublyUnderlineFm) |
| 82 |
testFunc(t, "Complex DoublyUnderline", DoublyUnderline(BrightBlue("x")), |
| 83 |
BrightFg|BlueFg|DoublyUnderlineFm) |
| 84 |
} |
| 85 |
|
| 86 |
func Test_Fraktur(t *testing.T) { |
| 87 |
testFunc(t, "Fraktur", Fraktur("x"), FrakturFm) |
| 88 |
testFunc(t, "Complex Fraktur", Fraktur(Faint("x").BgBrightCyan()), |
| 89 |
FaintFm|FrakturFm|BrightBg|CyanBg) |
| 90 |
} |
| 91 |
|
| 92 |
func Test_Italic(t *testing.T) { |
| 93 |
testFunc(t, "Italic", Italic("x"), ItalicFm) |
| 94 |
testFunc(t, "Complex Italic", Italic(BgBrightBlack("x")), |
| 95 |
ItalicFm|BrightBg|BlackBg) |
| 96 |
} |
| 97 |
|
| 98 |
func Test_Underline(t *testing.T) { |
| 99 |
testFunc(t, "Underline", Underline("x"), UnderlineFm) |
| 100 |
testFunc(t, "Complex Underline", Underline(Faint("x").Bold()), |
| 101 |
UnderlineFm|BoldFm) |
| 102 |
} |
| 103 |
|
| 104 |
func Test_SlowBlink(t *testing.T) { |
| 105 |
testFunc(t, "SlowBlink", SlowBlink("x"), SlowBlinkFm) |
| 106 |
testFunc(t, "Complex SlowBlink", SlowBlink(Reverse("x").Bold().Faint()), |
| 107 |
SlowBlinkFm|ReverseFm|FaintFm) |
| 108 |
} |
| 109 |
|
| 110 |
func Test_RapidBlink(t *testing.T) { |
| 111 |
testFunc(t, "RapidBlink", RapidBlink("x"), RapidBlinkFm) |
| 112 |
testFunc(t, "Complex RapidBlink", RapidBlink(Italic(Bold("x"))), |
| 113 |
RapidBlinkFm|ItalicFm|BoldFm) |
| 114 |
} |
| 115 |
|
| 116 |
func Test_Blink(t *testing.T) { |
| 117 |
testFunc(t, "Blink", Blink("x"), BlinkFm) |
| 118 |
testFunc(t, "Complex Blink", Blink(Reverse("x").Italic()), |
| 119 |
BlinkFm|ReverseFm|ItalicFm) |
| 120 |
} |
| 121 |
|
| 122 |
func Test_Reverse(t *testing.T) { |
| 123 |
testFunc(t, "Reverse", Reverse("x"), ReverseFm) |
| 124 |
testFunc(t, "Complex Reverse", Reverse(Italic("x").Reverse()), |
| 125 |
ReverseFm|ItalicFm|ReverseFm) |
| 126 |
} |
| 127 |
|
| 128 |
func Test_Inverse(t *testing.T) { |
| 129 |
testFunc(t, "Inverse", Inverse("x"), InverseFm) |
| 130 |
testFunc(t, "Complex Inverse", Inverse(Italic("x").Overlined()), |
| 131 |
InverseFm|ItalicFm|OverlinedFm) |
| 132 |
} |
| 133 |
|
| 134 |
func Test_Conceal(t *testing.T) { |
| 135 |
testFunc(t, "Conceal", Conceal("x"), ConcealFm) |
| 136 |
testFunc(t, "Complex Conceal", Conceal(Underline("x").Italic()), |
| 137 |
ConcealFm|UnderlineFm|ItalicFm) |
| 138 |
} |
| 139 |
|
| 140 |
func Test_Hidden(t *testing.T) { |
| 141 |
testFunc(t, "Hidden", Hidden("x"), HiddenFm) |
| 142 |
testFunc(t, "Complex Hidden", Hidden(Overlined("x")), |
| 143 |
HiddenFm|OverlinedFm) |
| 144 |
} |
| 145 |
|
| 146 |
func Test_CrossedOut(t *testing.T) { |
| 147 |
testFunc(t, "CrossedOut", CrossedOut("x"), CrossedOutFm) |
| 148 |
testFunc(t, "Complex CrossedOut", CrossedOut(BgRed("x")), |
| 149 |
CrossedOutFm|RedBg) |
| 150 |
} |
| 151 |
|
| 152 |
func Test_StrikeThrough(t *testing.T) { |
| 153 |
testFunc(t, "StrikeThrough", StrikeThrough("x"), StrikeThroughFm) |
| 154 |
testFunc(t, "Complex StrikeThrough", StrikeThrough(BgBrightCyan("x")), |
| 155 |
StrikeThroughFm|BrightBg|CyanBg) |
| 156 |
} |
| 157 |
|
| 158 |
func Test_Framed(t *testing.T) { |
| 159 |
testFunc(t, "Framed", Framed("x"), FramedFm) |
| 160 |
testFunc(t, "Complex Framed", Framed(Overlined("x").Underline()), |
| 161 |
FramedFm|OverlinedFm|UnderlineFm) |
| 162 |
} |
| 163 |
|
| 164 |
func Test_Encircled(t *testing.T) { |
| 165 |
testFunc(t, "Encircled", Encircled("x"), EncircledFm) |
| 166 |
testFunc(t, "Complex Encircled", Encircled(Italic("x").Overlined()), |
| 167 |
EncircledFm|ItalicFm|OverlinedFm) |
| 168 |
} |
| 169 |
|
| 170 |
func Test_Overlined(t *testing.T) { |
| 171 |
testFunc(t, "Overlined", Overlined("x"), OverlinedFm) |
| 172 |
testFunc(t, "Complex Overlined", Overlined(BgBrightWhite("x").Reverse()), |
| 173 |
OverlinedFm|BrightBg|WhiteBg|ReverseFm) |
| 174 |
} |
| 175 |
|
| 176 |
func Test_Black(t *testing.T) { |
| 177 |
testFunc(t, "Black", Black("x"), BlackFg) |
| 178 |
testFunc(t, "Complex Black", Black(Overlined("x").BgRed()), |
| 179 |
BlackFg|OverlinedFm|RedBg) |
| 180 |
} |
| 181 |
|
| 182 |
func Test_Red(t *testing.T) { |
| 183 |
testFunc(t, "Red", Red("x"), RedFg) |
| 184 |
testFunc(t, "Complex Red", Red(Inverse("x").DoublyUnderline()), |
| 185 |
RedFg|InverseFm|DoublyUnderlineFm) |
| 186 |
} |
| 187 |
|
| 188 |
func Test_Green(t *testing.T) { |
| 189 |
testFunc(t, "Green", Green("x"), GreenFg) |
| 190 |
testFunc(t, "Complex Green", Green(BgMagenta("x").Inverse().Reverse()), |
| 191 |
GreenFg|MagentaBg|InverseFm|ReverseFm) |
| 192 |
} |
| 193 |
|
| 194 |
func Test_Yellow(t *testing.T) { |
| 195 |
testFunc(t, "Yellow", Yellow("x"), YellowFg) |
| 196 |
testFunc(t, "Complex Yellow", Yellow(Bold("x").BgBrightMagenta()), |
| 197 |
YellowFg|BoldFm|BrightBg|MagentaBg) |
| 198 |
} |
| 199 |
|
| 200 |
func Test_Blue(t *testing.T) { |
| 201 |
testFunc(t, "Blue", Blue("x"), BlueFg) |
| 202 |
testFunc(t, "Complex Blue", Blue(Fraktur("x").Underline()), |
| 203 |
BlueFg|FrakturFm|UnderlineFm) |
| 204 |
} |
| 205 |
|
| 206 |
func Test_Magenta(t *testing.T) { |
| 207 |
testFunc(t, "Magenta", Magenta("x"), MagentaFg) |
| 208 |
testFunc(t, "Complex Magenta", Magenta(DoublyUnderline("x").Fraktur()), |
| 209 |
MagentaFg|DoublyUnderlineFm|FrakturFm) |
| 210 |
} |
| 211 |
|
| 212 |
func Test_Cyan(t *testing.T) { |
| 213 |
testFunc(t, "Cyan", Cyan("x"), CyanFg) |
| 214 |
testFunc(t, "Complex Cyan", Cyan(StrikeThrough("x")), |
| 215 |
CyanFg|StrikeThroughFm) |
| 216 |
} |
| 217 |
|
| 218 |
func Test_White(t *testing.T) { |
| 219 |
testFunc(t, "White", White("x"), WhiteFg) |
| 220 |
testFunc(t, "Complex White", White(Inverse("x").Blink()), |
| 221 |
WhiteFg|InverseFm|BlinkFm) |
| 222 |
} |
| 223 |
|
| 224 |
func Test_BrightBlack(t *testing.T) { |
| 225 |
testFunc(t, "BrightBlack", BrightBlack("x"), BrightFg|BlackFg) |
| 226 |
testFunc(t, "Complex BrightBlack", BrightBlack(BgBrightGreen("x")), |
| 227 |
BrightFg|BlackFg|BrightBg|GreenBg) |
| 228 |
} |
| 229 |
|
| 230 |
func Test_BrightRed(t *testing.T) { |
| 231 |
testFunc(t, "BrightRed", BrightRed("x"), BrightFg|RedFg) |
| 232 |
testFunc(t, "Complex BrightRed", BrightRed(Bold("x").BgYellow()), |
| 233 |
BrightFg|RedFg|BoldFm|YellowBg) |
| 234 |
} |
| 235 |
|
| 236 |
func Test_BrightGreen(t *testing.T) { |
| 237 |
testFunc(t, "BrightGreen", BrightGreen("x"), BrightFg|GreenFg) |
| 238 |
testFunc(t, "Complex BrightGreen", BrightGreen(Faint("x")), |
| 239 |
BrightFg|GreenFg|FaintFm) |
| 240 |
} |
| 241 |
|
| 242 |
func Test_BrightYellow(t *testing.T) { |
| 243 |
testFunc(t, "BrightYellow", BrightYellow("x"), BrightFg|YellowFg) |
| 244 |
testFunc(t, "Complex BrightYellow", BrightYellow(BgRed("x")), |
| 245 |
BrightFg|YellowFg|RedBg) |
| 246 |
} |
| 247 |
|
| 248 |
func Test_BrightBlue(t *testing.T) { |
| 249 |
testFunc(t, "BrightBlue", BrightBlue("x"), BrightFg|BlueFg) |
| 250 |
testFunc(t, "Complex BrightBlue", BrightBlue(DoublyUnderline("x")), |
| 251 |
BrightFg|BlueFg|DoublyUnderlineFm) |
| 252 |
} |
| 253 |
|
| 254 |
func Test_BrightMagenta(t *testing.T) { |
| 255 |
testFunc(t, "BrightMagenta", BrightMagenta("x"), BrightFg|MagentaFg) |
| 256 |
testFunc(t, "Complex BrightMagenta", BrightMagenta(Underline("x")), |
| 257 |
BrightFg|MagentaFg|UnderlineFm) |
| 258 |
} |
| 259 |
|
| 260 |
func Test_BrightCyan(t *testing.T) { |
| 261 |
testFunc(t, "BrightCyan", BrightCyan("x"), BrightFg|CyanFg) |
| 262 |
testFunc(t, "Complex BrightCyan", BrightCyan(BgGreen("x").Italic()), |
| 263 |
BrightFg|CyanFg|GreenBg|ItalicFm) |
| 264 |
} |
| 265 |
|
| 266 |
func Test_BrightWhite(t *testing.T) { |
| 267 |
testFunc(t, "BrightWhite", BrightWhite("x"), BrightFg|WhiteFg) |
| 268 |
testFunc(t, "Complex BrightWhite", BrightWhite(Inverse("x").BgRed()), |
| 269 |
BrightFg|WhiteFg|InverseFm|RedBg) |
| 270 |
} |
| 271 |
|
| 272 |
func Test_Index(t *testing.T) { |
| 273 |
testFunc(t, "Index", Index(178, "x"), (Color(178)<<shiftFg)|flagFg) |
| 274 |
testFunc(t, "Complex Index", Index(178, Inverse("x")), |
| 275 |
(Color(178)<<shiftFg|flagFg)|InverseFm) |
| 276 |
} |
| 277 |
|
| 278 |
func Test_Gray(t *testing.T) { |
| 279 |
testFunc(t, "Gray", Gray(14, "x"), Color(232+14)<<shiftFg|flagFg) |
| 280 |
testFunc(t, "Complex Gray", Gray(14, Index(19, "x").Bold()), |
| 281 |
flagFg|Color(14+232)<<shiftFg|BoldFm) |
| 282 |
} |
| 283 |
|
| 284 |
func Test_BgBlack(t *testing.T) { |
| 285 |
testFunc(t, "BgBlack", BgBlack("x"), BlackBg) |
| 286 |
testFunc(t, "Complex BgBlack", BgBlack(BgGray(15, "x")), |
| 287 |
BlackBg) |
| 288 |
} |
| 289 |
|
| 290 |
func Test_BgRed(t *testing.T) { |
| 291 |
testFunc(t, "BgRed", BgRed("x"), RedBg) |
| 292 |
testFunc(t, "Complex BgRed", BgRed(BrightBlack("x")), |
| 293 |
RedBg|BrightFg|BlackFg) |
| 294 |
} |
| 295 |
|
| 296 |
func Test_BgGreen(t *testing.T) { |
| 297 |
testFunc(t, "BgGreen", BgGreen("x"), GreenBg) |
| 298 |
testFunc(t, "Complex BgGreen", BgGreen(BrightGreen("x")), |
| 299 |
GreenBg|BrightFg|GreenFg) |
| 300 |
} |
| 301 |
|
| 302 |
func Test_BgYellow(t *testing.T) { |
| 303 |
testFunc(t, "BgYellow", BgYellow("x"), YellowBg) |
| 304 |
testFunc(t, "Complex BgYellow", BgYellow(Blink("x")), |
| 305 |
YellowBg|BlinkFm) |
| 306 |
} |
| 307 |
|
| 308 |
func Test_BgBlue(t *testing.T) { |
| 309 |
testFunc(t, "BgBlue", BgBlue("x"), BlueBg) |
| 310 |
testFunc(t, "Complex BgBlue", BgBlue(Framed("x")), |
| 311 |
BlueBg|FramedFm) |
| 312 |
} |
| 313 |
|
| 314 |
func Test_BgMagenta(t *testing.T) { |
| 315 |
testFunc(t, "BgMagenta", BgMagenta("x"), MagentaBg) |
| 316 |
testFunc(t, "Complex BgMagenta", BgMagenta(Encircled("x")), |
| 317 |
MagentaBg|EncircledFm) |
| 318 |
} |
| 319 |
|
| 320 |
func Test_BgCyan(t *testing.T) { |
| 321 |
testFunc(t, "BgCyan", BgCyan("x"), CyanBg) |
| 322 |
testFunc(t, "Complex BgCyan", BgCyan(StrikeThrough("x")), |
| 323 |
CyanBg|StrikeThroughFm) |
| 324 |
} |
| 325 |
|
| 326 |
func Test_BgWhite(t *testing.T) { |
| 327 |
testFunc(t, "BgWhite", BgWhite("x"), WhiteBg) |
| 328 |
testFunc(t, "Complex BgWhite", BgWhite(Inverse("x")), |
| 329 |
WhiteBg|InverseFm) |
| 330 |
} |
| 331 |
|
| 332 |
func Test_BgBrightBlack(t *testing.T) { |
| 333 |
testFunc(t, "BgBrightBlack", BgBrightBlack("x"), BrightBg|BlackBg) |
| 334 |
testFunc(t, "Complex BgBrightBlack", BgBrightBlack(BrightWhite("x")), |
| 335 |
BrightBg|BlackBg|BrightFg|WhiteFg) |
| 336 |
} |
| 337 |
|
| 338 |
func Test_BgBrightRed(t *testing.T) { |
| 339 |
testFunc(t, "BgBrightRed", BgBrightRed("x"), BrightBg|RedBg) |
| 340 |
testFunc(t, "Complex BgBrightRed", BgBrightRed(White("x")), |
| 341 |
BrightBg|RedBg|WhiteFg) |
| 342 |
} |
| 343 |
|
| 344 |
func Test_BgBrightGreen(t *testing.T) { |
| 345 |
testFunc(t, "BgBrightGreen", BgBrightGreen("x"), BrightBg|GreenBg) |
| 346 |
testFunc(t, "Complex BgBrightGreen", BgBrightGreen(BrightCyan("x")), |
| 347 |
BrightBg|GreenBg|BrightFg|CyanFg) |
| 348 |
} |
| 349 |
|
| 350 |
func Test_BgBrightYellow(t *testing.T) { |
| 351 |
testFunc(t, "BgBrightYellow", BgBrightYellow("x"), BrightBg|YellowBg) |
| 352 |
testFunc(t, "Complex BgBrightYellow", BgBrightYellow(Cyan("x")), |
| 353 |
BrightBg|YellowBg|CyanFg) |
| 354 |
} |
| 355 |
|
| 356 |
func Test_BgBrightBlue(t *testing.T) { |
| 357 |
testFunc(t, "BgBrightBlue", BgBrightBlue("x"), BrightBg|BlueBg) |
| 358 |
testFunc(t, "Complex BgBrightBlue", BgBrightBlue(Green("x")), |
| 359 |
BrightBg|BlueBg|GreenFg) |
| 360 |
} |
| 361 |
|
| 362 |
func Test_BgBrightMagenta(t *testing.T) { |
| 363 |
testFunc(t, "BgBrightMagenta", BgBrightMagenta("x"), BrightBg|MagentaBg) |
| 364 |
testFunc(t, "Complex BgBrightMagenta", BgBrightMagenta(Black("x")), |
| 365 |
BrightBg|MagentaBg|BlackFg) |
| 366 |
} |
| 367 |
|
| 368 |
func Test_BgBrightCyan(t *testing.T) { |
| 369 |
testFunc(t, "BgBrightCyan", BgBrightCyan("x"), BrightBg|CyanBg) |
| 370 |
testFunc(t, "Complex BgBrightCyan", BgBrightCyan(Yellow("x")), |
| 371 |
BrightBg|CyanBg|YellowFg) |
| 372 |
} |
| 373 |
|
| 374 |
func Test_BgBrightWhite(t *testing.T) { |
| 375 |
testFunc(t, "BgBrightWhite", BgBrightWhite("x"), BrightBg|WhiteBg) |
| 376 |
testFunc(t, "Complex BgBrightWhite", BgBrightWhite(Overlined("x")), |
| 377 |
BrightBg|WhiteBg|OverlinedFm) |
| 378 |
} |
| 379 |
|
| 380 |
func Test_BgIndex(t *testing.T) { |
| 381 |
testFunc(t, "BgIndex", BgIndex(187, "x"), Color(187)<<shiftBg|flagBg) |
| 382 |
testFunc(t, "Complex BgIndex", BgIndex(187, Italic("x")), |
| 383 |
Color(187)<<shiftBg|flagBg|ItalicFm) |
| 384 |
} |
| 385 |
|
| 386 |
func Test_BgGray(t *testing.T) { |
| 387 |
testFunc(t, "BgGray", BgGray(15, "x"), Color(232+15)<<shiftBg|flagBg) |
| 388 |
testFunc(t, "Complex BgGray", BgGray(15, Index(216, "x")), |
| 389 |
(Color(15+232)<<shiftBg)|flagBg|(Color(216)<<shiftFg)|flagFg) |
| 390 |
} |
| 391 |
|
| 392 |
func Test_Colorize(t *testing.T) { |
| 393 |
testFunc(t, "Colorize", Colorize("x", RedFg|BoldFm), RedFg|BoldFm) |
| 394 |
testFunc(t, "Complex Colorize", |
| 395 |
Colorize(Italic("x"), RedFg|BlueBg|BrightBg|BoldFm), |
| 396 |
RedFg|BlueBg|BrightBg|BoldFm, |
| 397 |
) |
| 398 |
} |
| 399 |
|
| 400 |
func Test_bigGray(t *testing.T) { |
| 401 |
testFunc(t, "Gray", Gray(115, "x"), Color(232+23)<<shiftFg|flagFg) |
| 402 |
testFunc(t, "BgGray", BgGray(215, "x"), Color(232+23)<<shiftBg|flagBg) |
| 403 |
} |
| 404 |
|
| 405 |
func Test_Hyperlink(t *testing.T) { |
| 406 |
assert.EqualValues(t, |
| 407 |
Value{ |
| 408 |
value: "Example", |
| 409 |
cc: DefaultColorizer.cc, |
| 410 |
hyperlink: &hyperlink{ |
| 411 |
target: "http://example.com", |
| 412 |
params: []HyperlinkParam{{ |
| 413 |
Key: "id", |
| 414 |
Value: "10", |
| 415 |
}}, |
| 416 |
}, |
| 417 |
}, |
| 418 |
Hyperlink("Example", "http://example.com", HyperlinkID("10"))) |
| 419 |
|
| 420 |
assert.EqualValues(t, |
| 421 |
Value{ |
| 422 |
value: "Example", |
| 423 |
cc: DefaultColorizer.cc | colorConfig(RedFg), |
| 424 |
hyperlink: &hyperlink{ |
| 425 |
target: "http://example.com", |
| 426 |
params: []HyperlinkParam{{ |
| 427 |
Key: "id", |
| 428 |
Value: "10", |
| 429 |
}}, |
| 430 |
}, |
| 431 |
}, |
| 432 |
Hyperlink(Red("Example"), "http://example.com", HyperlinkID("10"))) |
| 433 |
} |
| 434 |
|
| 435 |
func Test_HyperlinkTarget(t *testing.T) { |
| 436 |
assert.Equal(t, "", HyperlinkTarget("Example")) |
| 437 |
assert.Equal(t, "http://example.com", |
| 438 |
HyperlinkTarget(Hyperlink( |
| 439 |
Red("Example"), "http://example.com", HyperlinkID("10")), |
| 440 |
)) |
| 441 |
} |
| 442 |
|
| 443 |
func Test_HyperlinkParams(t *testing.T) { |
| 444 |
assert.Equal(t, HyperlinkParams(nil), HyperlinkParams("Example")) |
| 445 |
assert.EqualValues(t, |
| 446 |
[]HyperlinkParam{{ |
| 447 |
Key: "id", |
| 448 |
Value: "10", |
| 449 |
}}, |
| 450 |
HyperlinkParams(Hyperlink( |
| 451 |
Red("Example"), "http://example.com", HyperlinkID("10")), |
| 452 |
)) |
| 453 |
} |