Repo Browser

bashcards/bashcards-bashcards
cards/076196934745--test/assets/raw.sh
#!/usr/bin/env bash
set +e
tt="/dev/tty";[[ -r "$tt" && -w "$tt" ]]||tt=""
p(){ [[ -n "$tt" ]]&&printf "%b" "$1" >"$tt"||printf "%b" "$1"; }
r(){ local t=""; if [[ -n "$tt" ]]; then IFS= read -r t <"$tt" || t=""; else IFS= read -r t || t=""; fi; printf "%s" "$t"; }

W=60
deck="EDU";subject="EDU";
topic="Software Testing Basics";
subtitle="Introduction to Testing";
note="Testing is like checking your homework to catch mistakes early. Whether you are a kid or an adult, learning to test helps make software safer and better.";
cl(){ printf "\033[2J\033[H"; }
bar(){ printf "%s\n" "$(printf "%*s" "$W" "" | tr " " "=")"; }
row(){ printf "| %-*.*s |\n" "$((W-4))" "$((W-4))" "$1"; }
wrap(){
  local txt="$1" max=$((W-4)) chunk rest cut
  while [[ -n "$txt" ]]; do
    if [[ ${#txt} -le $max ]]; then row "$txt"; break; fi
    chunk=${txt:0:$max}
    rest=${txt:$max}
    if [[ "$chunk" =~ (.+)[[:space:]] ]]; then
      cut=${BASH_REMATCH[1]}
      row "$cut"
      txt="${txt:${#cut}}"; txt="${txt#" "}";
    else
      row "$chunk"
      txt="$rest"
    fi
  done
}
pause(){ p "Press Enter to continue: "; r >/dev/null; }

menu(){
  cl
  bar; row "$deck • $subject"; bar
  wrap "$topic"
  wrap "$subtitle"
  if [[ -n "$note" ]]; then wrap "Tip: $note"; fi
  bar
  row "1) OVERVIEW"
  row "2) STEPS"
  row "3) TERMINOLOGY"
  row "q) EXIT"
  bar
  p "> "
}

page_OVERVIEW(){
  cl
  bar; row "OVERVIEW"; bar
  local s
  p=(
"Testing checks if software works correctly."
"It helps find and fix errors early."
"Testing improves software quality and reliability."
"There are different types of tests for different needs."
"Automated tests run code checks automatically."
"Manual tests involve human checking and feedback."
)
  for s in "${p[@]}"; do wrap "$s"; done
  bar
  pause
}

page_STEPS(){
  cl
  bar; row "STEPS"; bar
  local s
  p=(
"Understand the purpose of testing in software development."
"Learn common types of tests: unit, integration, system, acceptance."
"Write simple test cases to check small parts of code."
"Run tests and observe results carefully."
"Fix any problems found during testing."
"Repeat tests after changes to ensure stability."
)
  for s in "${p[@]}"; do wrap "$s"; done
  bar
  pause
}

page_TERMINOLOGY(){
  cl
  bar; row "TERMINOLOGY"; bar
  local s
  p=(
"Test Case — a set of conditions to check software behavior"
"Bug — an error or flaw in software"
"Unit Test — testing a small piece of code independently"
"Integration Test — testing combined parts of software"
"System Test — testing the complete software system"
"Acceptance Test — checking if software meets user needs"
"Automated Test — tests run by software tools without manual effort"
"Manual Test — tests performed by a person"
)
  for s in "${p[@]}"; do wrap "$s"; done
  bar
  pause
}

while true; do
  menu
  read -r choice < "${tt:-/dev/stdin}" || choice=""
  case "$choice" in
    1) page_OVERVIEW ;;
    2) page_STEPS ;;
    3) page_TERMINOLOGY ;;
    q|Q) cl; bar; row "CARD CLOSED"; bar; p "\n"; break ;;
    *) cl; bar; row "Select 1-3 or q"; bar; pause ;;
  esac
done
NameTypeSize
auto-art.pngfile1,494,614
back-data-url.txtfile238,818
back-thumb.pngfile163,242
back.pngfile179,097
front-data-url.txtfile219,086
front-thumb.pngfile95,875
front.pngfile164,297
manifest.txtfile206
print-card.pdffile212,805
qr-payload.txtfile3,226
raw.shfile3,094