Thread: Boundary condition

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    175

    Boundary condition

    Hello,

    I am newbie in testing field.

    I have been told to test boundary condition. What exactly does that mean?

    Please let know.

    Tiger

  2. #2
    Registered User Cela's Avatar
    Join Date
    Jan 2003
    Posts
    362
    Let's say you read an int and it has to be between 0 and 10, you check the boundaries like this
    Code:
    if (num < 0 || num > 10)
    {
      error();
    }
    Or you can check the index of an array in a similar manner :-)
    *Cela*

  3. #3
    Registered User
    Join Date
    Feb 2003
    Posts
    175
    Thanks Cela

    I wanted to know, what does mean by memory boundary condition checking?

    Is it like, how much heap or stack grows and shrinks? But I am not allocating any memory over heap at all.

    Please explain

  4. #4
    Registered User Cela's Avatar
    Join Date
    Jan 2003
    Posts
    362
    >>I wanted to know, what does mean by memory boundary condition checking?
    If you have an array
    Code:
    int a[10];
    You check the index to make sure you don't access memory outside of your boundaries, for example, a[i] would go out of bounds if i is 10 or greater, or less than 0, so you might check it like this
    Code:
    if (i >= 0 && i < 10)
    {
      a[i]; /* Safe */
    }
    *Cela*

  5. #5
    Registered User
    Join Date
    Feb 2003
    Posts
    175
    Here are my comments
    1. Say I am using this array 100 times in code. Do I need to check the boundary condition every time code accesses the array?

    2. This is basically an embedded system that running on some on target, do you still feel that we have to test boundary conditions in firmware code itself? Don’t you think it will affect the performance? In short, what I want to know is, does adding new code alone check boundary conditions?

    3. We have a system (PC) that talks to this target board over RS232. And PC issue commands. Is there any way to test the boundary condition by issuing valid and invalid( crossing boundaries) commands?


    Please let me know

    Tiger

  6. #6
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Originally posted by Roaring_Tiger
    Here are my comments
    1. Say I am using this array 100 times in code. Do I need to check the boundary condition every time code accesses the array?
    Whenever you use an array, you ALWAYS check your boundries. Never go below zero, and never above SIZE-1.

    The easiest way to do this is:

    array[ some_var % SIZE ]

    Now, this may not give you the right answer in the event your 'some_var' is out of bounds, but it will keep your program from crashing by forcing the value into the bounds of the array.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. condition variable on read/write locks
    By ShwangShwing in forum C Programming
    Replies: 3
    Last Post: 04-29-2009, 09:32 AM
  2. Condition variables
    By sethjackson in forum Windows Programming
    Replies: 16
    Last Post: 03-19-2008, 11:42 AM
  3. SDL Condition variables.
    By antex in forum Game Programming
    Replies: 3
    Last Post: 11-11-2005, 07:11 AM
  4. Race condition
    By Roaring_Tiger in forum C Programming
    Replies: 5
    Last Post: 10-24-2004, 09:42 PM
  5. Boundary condition
    By Juganoo in forum C Programming
    Replies: 1
    Last Post: 01-21-2003, 07:07 PM