Testing Boolean Expressions

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

Overview Functional Testing Boundary Value Testing (BVT)
14004 L5 - © D. Deugo, Lecture 5 Combinational Models (Binder chapter 6)
Chapter 5 Decisions. Outline and Objectives Relational and Logical Operators If Blocks Select Case Blocks.
1 Selection Structures. 2 Making Decisions Sample assignment statements to figure worker pay with possible overtime PayAmount = Hours * Rate PayAmount.
Compunet Corporation1 Programming with Visual Basic.NET Arithmetic, Logical & Bitwise Operators Week # 3 Tariq Ibn Aziz.
1 Software Testing Techniques CIS 375 Bruce R. Maxim UM-Dearborn.
Equivalence Class Testing
New Mexico Computer Science For All Booleans and Logic Maureen Psaila-Dombrowski.
True or False Unit 3 Lesson 7 Building Blocks of Decision Making With Additions & Modifications by Mr. Dave Clausen True or False.
Programming Logic and Design Sixth Edition
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 4 Decision Structures and Boolean Logic.
Decision Structures and Boolean Logic
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
Lecture 7 Topics –Boolean Algebra 1. Logic and Bits Operation Computers represent information by bit A bit has two possible values, namely zero and one.
Computer Science 210 Computer Organization Introduction to Boolean Algebra.
Rational Expressions and selection structures Relational operators Logical operators Selection structures.
CHAPTER 4: Selection Control Structure. Objectives  Use the relational comparison operators  Learn about AND logic  Learn about OR logic  Make selections.
Summarizing “Structural” Testing Now that we have learned to create test cases through both: – a) Functional (blackbox)and – b) Structural (whitebox) testing.
Today’s Agenda  Reminder: HW #1 Due next class  Quick Review  Input Space Partitioning Software Testing and Maintenance 1.
Chapter 5: Making Decisions. Objectives Plan decision-making logic Make decisions with the if and if…else structures Use multiple statements in if and.
By: Mr. Baha Hanene Chapter 6. LEARNING OUTCOMES This chapter will cover the learning outcome 02 i.e. 2.Use basic data-types and input / output in C programs.
Department of Electronic & Electrical Engineering Lecture 3 IO reading and writing variables scanf printf format strings "%d %c %f" Expressions operators.
Rational Expressions relational operators logical operators order of precedence.
ACSL INTRODUCES A NEW ELEMENTARY DIVISION. Registration Any student in grades may participate as part of a registered school or organization. Each.
CMSC201 Computer Science I for Majors Lecture 05 – Comparison Operators and Boolean (Logical) Operators Prof. Katherine Gibson Prof. Jeremy.
Morgan Kaufmann Publishers
Computer Science 210 Computer Organization
DeMorgan’s Theorem DeMorgan’s 2nd Theorem
Boolean expressions and if-else statements
Selection (also known as Branching) Jumail Bin Taliba by
Rational Expressions. relational operators. logical operators
EGR 2261 Unit 4 Control Structures I: Selection
Other Kinds of Arrays Chapter 11
Boolean Expressions Lecture No. 10.
Topics The if Statement The if-else Statement Comparing Strings
Structural testing, Path Testing
Circuits & Boolean Expressions
Overview Functional Testing Boundary Value Testing (BVT)
Week 3 Logic will get you from A to B. Imagination will take you everywhere. Albert Einstein.
Topics The if Statement The if-else Statement Comparing Strings
Karnaugh Maps References: Lecture 4 from last semester
Conditions and Ifs BIS1523 – Lecture 8.
CSE 370 – Winter Combinational Logic - 1
Relational Operators Operator Meaning < Less than > Greater than
Karnaugh Maps Topics covered in this presentation: Karnaugh Maps
DESICION TABLE Decision tables are precise and compact way to model complicated logic. Decision table is useful when input and output data can be.
Computer Science 210 Computer Organization
Boolean Logic Boolean Logic is considered to be the basic of digital electronics. We know that a computer’s most basic operation is based on digital electronics.
Control Structure Testing
From now on: Combinatorial Circuits:
Digital Fundamentals Floyd Chapter 4 Tenth Edition
SE1H421 Procedural Programming LECTURE 4 Operators & Conditionals (1)
Overview Functional Testing Boundary Value Testing (BVT)
Chapter 3: Selection Structures: Making Decisions
Boolean Expressions to Make Comparisons
ECE 352 Digital System Fundamentals
Chapter 5 Decisions.
Winter 2019 CISC101 4/16/2019 CISC101 Reminders
Chapter 3: Selection Structures: Making Decisions
Evaluating Boolean expressions
Basic circuit analysis and design
Overview Functional Testing Boundary Value Testing (BVT)
Using C++ Arithmetic Operators and Control Structures
OPERATORS in C Programming
The IF Revisited A few more things Copyright © Curt Hill.
Circuits & Boolean Expressions
Week 3 Logic will get you from A to B. Imagination will take you everywhere. Albert Einstein.
Boolean Expressions September 1, 2019 ICS102: The course.
OPERATORS in C Programming
Presentation transcript:

Testing Boolean Expressions September 14, 2005 Cem Kaner Several concepts freely pilfered from Brian Marick http://www.testing.com/writings/half-day-programmer.pdf David Gelperin

Booleans? An expression that evaluates to True (1) or False (0) For example: True is True (True and False) is False (5 < 2) is 0 ((2 < 5) OR 1) AND 0)is 0

We can lay this out in truth tables A and B 1

We can lay this out in truth tables A or B 1

We can lay this out in truth tables Not (A and B) 1

But sometimes they get a bit unwieldy C D (A and B) or (C and D) 1

Sometimes a wee bit confusing D Not(A and B) or (C and Not-D) 1

Boolean Challenges If (boolean) Sooooooo … True  Do the True thing False  Do the False thing Sooooooo … Every line in the truth table is a different test Combinatorial explosion = 2^N Boolean expressions are abstractions Consider: IF (5 < x) If x is an Int, how many tests are possible?

Boolean Strategy – Step 1 Reduce the number of tests with a domain analysis Consider (5 < x) Test with what values for x? What about the other values? Is it possible to have failures that are triggered by the other values?

Boolean Strategy – Step 1 Ultimately, you reduce the number of tests for a given comparison (or other result) to a minimum In analyzing expression, a simple comparison, like 5 < x, becomes a single True/False column 5 X 5 < x 6 1 4 ? 0 ? MinInt? MaxInt?

Booleanisms – Step 2 Assess the complexity of the boolean Is a programmer likely to misunderstand whether (5 < x) is True or False (given that she knows the value of x)? How many programmers are likely to get every decision right for: (NOT((a OR b) AND NOT-c) OR NOT-d AND (b OR (NOT-d AND c))) AND A For a complex expression, you should test several combinations

Step 3 -- Sampling In an expression involving N logical variables, there are 2^N combinations and thus 2^N possible tests Any of these combinations could (in theory) yield a unique failure Don’t forget Hoffman’s MASPAR experience But there’s not enough time, so we have to sample The question is, what is our sampling theory?

Sampling (2) Good testing based on risk Domain testing, for example, focuses on risk of classification error, either by mishandling an entire category so we test every equivalence class or by misclassifying members of a category so we test boundaries as the most possible tests of sub-range mis-classification For binary variables, we have to use a different subsetting strategy

Sampling (3) In an expression, we have: Variables, V = 0 or 1 Operators = NOT, OR, AND Parentheses Result, R = 0 or 1 Let’s pretend that the programmer has perfect empirical knowledge: Given values for V1, V2, …, Vn, the programmer knows the correct R, for all combinations of Vi’s.

Sampling (4) Given perfect empirical knowledge, the error is in the creation of the model (the boolean expression that is supposed to capture the intended relation). If the programmer makes only one mistake: Parenthesis misplaced Evaluation order wrong Scope of an operator wrong Wrong operator (A or B) Missing, added, or misplaced NOT Wrong interpretation of the scope and effect of a NOT

Sampling (5) We can’t do all 2^N cases Suppose we adopt 0-error model … N error model

Sampling 6: Zero-Error Model The expression is coded correctly We test two branches: Expression result TRUE Expression result FALSE We might also test special cases that involve side-effects of the calculations (e.g. if we know there is extensive memory cost of a given calculation), but these are an orthogonal dimension to the logic-combination so I’ll skip them

Sampling 7: One-Error Model Consider expression a AND b AND c Make exactly one mistake: (a OR b) AND c a AND b a OR (b AND c) a AND c a AND (b OR c) b AND c (a AND b) OR c a (a OR c) AND b b NOT-a AND b AND c c a AND NOT-b AND c a AND b AND NOT-c The sampling strategy is to pick the smallest set of tests that will cover these mistakes

White, red, orange  0; blue  1 c a&b&c (a||b)&c a||(b&c) a&(b||c) (a&b)||c (a||c)&b a||b||c 1 a&b a&c b&c ~a&b&c a&~b&c a&b&~c White, red, orange  0; blue  1

Another One-Error Example --- Red, orange  1, grey, purple  0 b c a||(b&c) (a||b)&c a&b&c a||b||c ~a||(b&c) a||~(b&c) 1 a||(~b&c) a||(b&~c) (b&c) a||b a||c Another One-Error Example --- Red, orange  1, grey, purple  0