Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- r = randint
- a = []
- u = set()
- def init():
- global a
- a[:] = []
- print('my_vector::my_vector <T> a;')
- def push():
- global a
- a.append(0)
- print('a.push_back(T());')
- print('assert(a.size() == ' + str(len(a)) + ');')
- def pop():
- global a
- if len(a) > 0:
- a.pop()
- print('a.pop_back();')
- print('assert(a.size() == ' + str(len(a)) + ');')
- def empty():
- global a
- print('assert(a.empty() == ' + str(int(len(a) == 0)) + ');')
- def size():
- global a
- print('assert(a.size() == ' + str(len(a)) + ');')
- def reserve(x):
- global a
- print('a.reserve(' + str(x) + ');')
- def resize(x):
- global a
- if x <= len(a):
- a[:] = a[:x]
- else:
- a += [0 for i in range(x - len(a))]
- print('a.resize(' + str(x) + ');')
- print('assert(a.size() == ' + str(len(a)) + ');')
- def clear():
- global a
- a[:] = []
- print('a.clear();')
- print('assert(a.empty() == true);')
- def idx(i):
- global a
- a[i] = 0
- print('a[' + str(i) + '] = T();')
- def chaos():
- abc = 'abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ'
- names = []
- while len(names) < 10:
- s = ''.join([abc[r(0, len(abc) - 1)] for i in range(1, 10)])
- if s in u:
- continue
- u.add(s)
- names.append(s)
- print('my_vector::my_vector <T> ' + names[0] + ';')
- for i in names[1:-1]:
- print('my_vector::my_vector <T> ' + i + '(' + str(r(1, 50)) + ');')
- print('my_vector::my_vector <T> ' + names[-1] + '(' + names[r(0, 1)] + ');')
- for i in range(10):
- idx = r(0, 9)
- jdx = r(0, 9)
- qdx = r(0, 9)
- print(names[idx] + ' = ' + names[jdx] + ' = ' + names[qdx] + ';')
- print('assert(' + names[idx] + '.size() == ' + names[jdx] + '.size());')
- print('assert(' + names[idx] + '.size() == ' + names[qdx] + '.size());')
- print('assert(' + names[qdx] + '.size() == ' + names[jdx] + '.size());')
- init()
- mx = 50
- zero = [push, pop, clear, empty, size]
- one = [resize, reserve]
- for j in range(20):
- for i in range(1, r(1, mx)):
- for k in range(10):
- zero[r(0, len(zero) - 1)]()
- one[r(0, len(one) - 1)](r(1, mx))
- if len(a) > 0:
- idx(r(0, len(a) - 1))
- chaos()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement