input: Write a function to slice a string using the given start and end indices, and return the resulting substring. If the provided string is empty or the indices are invalid, return an empty string. The function should handle cases where start or end indices are out of bounds by adjusting them to the nearest valid index. The function should also account for negative indices.
  
  assert slicing("This is a slicing test", 8, 15) == "a slicing"
  assert slicing("This is a slicing test", 8, 20) == "a slicing test"
  assert slicing("This is a slicing test", 100, 15) == ""
  assert slicing("", 8, 15) == ""
  assert slicing("This is a slicing test", -5, -1) == "test"
  assert slicing("This is a slicing test", -1, -5) == ""
output: def slicing(s, start, end):
      if not s:
          return ""
      length = len(s)
      if start < 0:
          start = max(0, start + length)
      else:
          start = min(start, length)
      if end < 0:
          end = max(0, end + length)
      else:
          end = min(end, length)
      return s[start:end]