Пример #1
0
void test_of_reverse_for_CHAR_TYPE(){
  Linked_list list=createList();
  char _0th='Y',_1st='S',_2nd='e',_3rd='e',_4th='t',_5th='a',_6th=' ',_7th='R',_8th='a',_9th='m';
    
  add_to_list(&list,&_0th);
  add_to_list(&list,&_1st);
  add_to_list(&list,&_2nd);
  add_to_list(&list,&_3rd);
  add_to_list(&list,&_4th);
  add_to_list(&list,&_5th);
  add_to_list(&list,&_6th);
  add_to_list(&list,&_7th);
  add_to_list(&list,&_8th);
  add_to_list(&list,&_9th);

  Linked_list reversed_list = reverse(list);
  Element *e0=getElementAt(reversed_list,0);
  Element *e8=getElementAt(reversed_list,8);
  Element *e3=getElementAt(reversed_list,3);
  Element *e2=getElementAt(reversed_list,2);
  Element *e9=getElementAt(reversed_list,9);

  assert(TYPECHAR(e0->value)=='m');
  assert(TYPECHAR(e8->value)=='S');
  assert(TYPECHAR(e3->value)==' ');
  assert(TYPECHAR(e2->value)=='R');
  assert(TYPECHAR(e9->value)=='Y');
}
Пример #2
0
void test_for_getElementAt_returns_the_value_at_index_char_type_of_list(){
  Linked_list list = createList();
  int _0th,_1st,_2nd,_3rd,_4th;
  _0th ='A';
  _1st ='B';
  _2nd ='b';
  _3rd ='a';
  _4th ='A';
  add_to_list(&list ,&_0th);
  add_to_list(&list ,&_1st);
  add_to_list(&list ,&_2nd);
  add_to_list(&list ,&_3rd);
  add_to_list(&list ,&_4th);
  
  Element *e0=getElementAt(list,0);
  Element *e1=getElementAt(list,1);
  Element *e2=getElementAt(list,2);
  Element *e3=getElementAt(list,3);
  Element *e4=getElementAt(list,4);


  assert(TYPECHAR(e0->value)=='A');
  assert(TYPECHAR(e1->value)=='B');
  assert(TYPECHAR(e2->value)=='b');
  assert(TYPECHAR(e3->value)=='a');
  assert(TYPECHAR(e4->value)=='A');

  assert(getElementAt(list,9)==NULL);
}
Пример #3
0
void test_for_add_to_list_it_add_CHAR_type_ELEMENT_at_the_end_of_list(){
  Linked_list list = createList();
  char _1st = 'K',_2nd='9';
  assert(1==add_to_list(&list ,&_1st));
  assert(2==add_to_list(&list ,&_2nd));

  assert(TYPECHAR(list.head->value)=='K');
  assert(TYPECHAR(list.tail->value)=='9');
  assert(list.length==2);

}
Пример #4
0
void test_for_get_last_element_returns_last_element_from_the_CHAR_type_of_list(){
  Linked_list list = createList();
  char _1st,_2nd,_3rd;
  _1st ='a';
  _2nd ='g';
  _3rd ='9';
  add_to_list(&list ,&_1st);
  add_to_list(&list ,&_2nd);
  add_to_list(&list ,&_3rd);
  assert(TYPECHAR(get_last_element(list))=='9');
}
Пример #5
0
void test_for_deleteElement_it_delete_the_LAST_element_of_CHAR_type_from_list(){
  Linked_list list=createList();
  char _1st ='A',_2nd='a',_3rd='b';
  add_to_list(&list,&_1st);
  add_to_list(&list,&_2nd);
  add_to_list(&list,&_3rd);

  
  assert(list.length==3);
  assert(TYPECHAR(list.head->value)==_1st);
  assert(TYPECHAR(list.tail->value)==_3rd);


  deleteElementAt(&list,list.length-1);
   
  assert(TYPECHAR(list.head->value)==_1st);
  assert(TYPECHAR(list.tail->value)==_2nd);
  assert(list.length==2);


}
Пример #6
0
/*
 * Return the standard ls-like mode string from a file mode.
 * This is static and so is overwritten on each call.
 */
const char *mode_string(int mode)
{
	static char buf[12];

	int i;

	buf[0] = TYPECHAR(mode);
	for (i = 0; i < 9; i++) {
		if (mode & SBIT[i])
			buf[i + 1] = (mode & MBIT[i]) ? SMODE1[i] : SMODE0[i];
		else
			buf[i + 1] = (mode & MBIT[i]) ? MODE1[i] : MODE0[i];
	}
	return buf;
}